Jesse
09/01/2025, 2:39 PMMarvin
09/01/2025, 2:39 PMMarvin
09/01/2025, 2:41 PMprefect version
- Which exact command(s) are saying “not authenticated,” and what’s the full error text?
- Are you running in a container/CI or setting any PREFECT_*
environment variables?
In Prefect 3.x, profiles can be overridden by environment variables (they take precedence). That’s the most common reason for “I’m logged in but still unauthenticated.”
Here are quick checks and remedies:
1) Confirm the active profile and its settings
prefect profile ls
prefect profile inspect
prefect config view
You should see PREFECT_API_URL
pointing to Cloud and a PREFECT_API_KEY
set (the key value will be redacted in output).
2) Check for environment overrides
- macOS/Linux:
env | grep PREFECT_
- Windows (PowerShell):
gci env:PREFECT_*
If PREFECT_API_URL
is set here but PREFECT_API_KEY
is missing (or vice versa), the CLI can appear “not authenticated.” Unset the problematic env var(s) or align them with your profile.
3) Verify workspace and session
prefect cloud workspace ls
prefect cloud open
If the workspace isn’t set or is wrong, set it:
prefect cloud workspace set <account_handle>/<workspace_handle>
4) Re-login (quick reset)
prefect cloud logout
prefect cloud login
Or explicitly:
prefect cloud login -k <API_KEY> -w <account_handle>/<workspace_handle>
5) Validate config
prefect config validate
If you share:
- the output of prefect version
- the output of prefect profile inspect
(redact your key)
- the exact command and error text
- any PREFECT_*
env vars
…I can pinpoint the cause and get you back in business fast.Jesse
09/01/2025, 2:46 PM$ poetry run prefect version
Version: 3.4.14
API version: 0.8.4
Python version: 3.13.7
Git commit: 9e2d422b
Built: Thu, Aug 21, 2025 04:05 PM
OS/Arch: darwin/arm64
Profile: cloud
Server type: cloud
Pydantic version: 2.11.7
Integrations:
prefect-aws: 0.5.13
prefect-slack: 0.3.1
$ poetry run prefect profile inspect
No name provided, defaulting to 'cloud'
PREFECT_API_KEY='pnu_XXXX'
PREFECT_API_URL='<https://api.prefect.cloud/api/accounts/XXXX/workspaces/XXXX>'
Marvin
09/01/2025, 2:48 PMMarvin
09/01/2025, 2:49 PMpoetry run prefect profile ls
poetry run prefect profile inspect
poetry run prefect config view
poetry run prefect config validate
- Check for any PREFECT_* environment variables that could be overriding your profile (especially an empty or mismatched PREFECT_API_KEY
or PREFECT_API_URL
):
- macOS/Linux:
poetry run env | grep PREFECT_
- Windows (PowerShell):
poetry run powershell -NoProfile -Command "gci env:PREFECT_*"
- Quick Cloud checks:
poetry run prefect cloud workspace ls
poetry run prefect cloud open
If you see any PREFECT_API_*
values in the env that differ from your profile (or PREFECT_API_KEY
is blank), unset/fix them in your shell or Poetry’s environment and try again. Then, if needed, do a clean reset:
poetry run prefect cloud logout
poetry run prefect cloud login -k <API_KEY> -w <account_handle>/<workspace_handle>
If it still fails, please share:
- The exact command that says “not authenticated” and the full error text
- Output of:
- poetry run prefect config view
- poetry run env | grep PREFECT_
- Optionally, rerun the failing command with debug logs:
PREFECT_LOGGING_LEVEL=DEBUG poetry run prefect <your-command>
With that, I can zero in on the cause quickly.Jesse
09/03/2025, 2:50 PM