# p0 login

Below is a troubleshooting guide for `p0 login`

***

| Symptom                                                                                                           | Cause                                                                                                                            | Resolution                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Error:** The P0 organization ID is required. Please provide it as an argument or set `P0_ORG`.                  | You ran `p0 login` without supplying `<org-id>` and haven’t defined the `P0_ORG` environment variable.                           | <p>1. <strong>One-off login:</strong> <code>bash p0 login my-org-id</code><br><br>2. <strong>Persistent env var:</strong> <code>bash export P0\_ORG=my-org-id p0 login</code><br><br>3. <strong>Verify:</strong> <code>bash echo $P0\_ORG # should output your org slug</code></p>                                                                                                                                                                                        |
| **Error:** Could not find organization                                                                            | The CLI reached Firestore but did not match any record to your `<org-id>`.                                                       | <p><strong>Exact match:</strong> Confirm the slug matches (case-sensitive) your P0 admin’s value.-<br><br><strong>Network:</strong> Ensure outbound HTTPS to <code>\*.firebaseio.com</code> isn’t blocked by VPN/firewall.<br><br><strong>Reset var:</strong> <code>bash\<br> unset P0\_ORG\<br> p0 login correct-org-id\<br></code> -<br></p><p><strong>Debug:</strong> Run with <code>DEBUG=plugin-login p0 login my-org-id</code> to see request/response details.</p> |
| **Symptom:** No browser window appears and “Waiting for authentication…” hangs indefinitely.                      | • No default browser is configured (or `$BROWSER` isn’t set).• A pop-up blocker or privacy setting is preventing the SSO window. | <p><strong>Set browser manually:</strong> <code>bash\<br> export BROWSER=google-chrome # or "firefox" / "open" on macOS\<br></code></p><p><strong>Allow pop-ups:</strong> Enable pop-ups for the P0 login domain in your browser settings.</p><p><strong>Headless/server:</strong> • Use SSH with X11 forwarding (<code>ssh -X</code>). • Or run <code>p0 login</code> locally on your desktop.</p>                                                                       |
| **Error:** EACCES: permission denied, open '\~/.p0/config.json'                                                   | Your home directory or the `~/.p0` folder isn’t owned or writable by your user account.                                          | <p>1. <strong>Fix permissions:</strong> <code>bash\<br> mkdir -p \~/.p0\<br> chown $(whoami):$(whoami) \~/.p0\<br> chmod 700 \~/.p0\<br></code></p><p>2. <strong>Verify ownership:</strong> <code>bash\<br> ls -ld \~/.p0\<br></code></p><p>3. <strong>Retry login:</strong> <code>bash\<br> p0 login my-org-id\<br></code></p>                                                                                                                                           |
| **Symptom:** Every command asks you to login again, or you see “Please run `p0 login <organization>` to use CLI.” | Your saved token has expired or could not be auto-refreshed due to clock skew or missing refresh grant.                          | <p>F<strong>ull logout & login:</strong> <code>bash\<br> p0 logout # clears \~/.p0/config.json and identity token\<br> p0 login my-org-id\<br></code></p><p><strong>Clock sync:</strong> Ensure your system clock is accurate: <code>bash\<br> sudo ntpdate pool.ntp.org # or use your OS’s time-sync service\<br></code></p>                                                                                                                                             |
| **Error:** Could not find organization, logging out immediately after SSO                                         | You authenticated successfully, but the tenant-access check failed because your user isn’t in that P0 org.                       | <p>1. <strong>Access rights:</strong> Confirm your user account is added to the correct P0 tenant in the P0 web UI.</p><p>2. <strong>Org slug:</strong> Verify you’re logging into the exact org slug your admin provided.</p><p>3. <strong>Support:</strong> If everything looks correct, share your SSO assertion logs with <a href="mailto:support@p0.dev"><support@p0.dev></a>.</p>                                                                                   |

**Quick Cleanup & Full Retry**

```bash
p0 logout
rm -rf ~/.p0
p0 login <your-org-id>
```

**Still having trouble?**\
Email [**support@p0.dev**](mailto:support@p0.dev) with:

* Your org slug
* Full error message and stack trace
* Relevant env vars (`P0_ORG`, `BROWSER`, system time, etc.)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.p0.dev/p0-cli/troubleshooting/p0-login.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
