<@ULVA73B9P>: I’m logged in locally in the CLI, bu...
# marvin-ai
j
@Marvin: I’m logged in locally in the CLI, but when I run different commands, it says I’m not authenticated. I’ve checked that I’m using the right profile.
m
thought for 138.9 seconds
Got it — let’s figure out why the CLI thinks you’re unauthenticated even though you’re logged in. A few quick questions to pinpoint it: - What’s your Prefect version? Please run:
Copy code
prefect 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
Copy code
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:
Copy code
env | grep PREFECT_
- Windows (PowerShell):
Copy code
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
Copy code
prefect cloud workspace ls
prefect cloud open
If the workspace isn’t set or is wrong, set it:
Copy code
prefect cloud workspace set <account_handle>/<workspace_handle>
4) Re-login (quick reset)
Copy code
prefect cloud logout
prefect cloud login
Or explicitly:
Copy code
prefect cloud login -k <API_KEY> -w <account_handle>/<workspace_handle>
5) Validate config
Copy code
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.
j
@Marvin:
Copy code
$ 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
Copy code
$ 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>'
m
thought for 84.4 seconds
Thanks for the details — your profile looks correct and you’re on Prefect 3.4.14. The most common cause of “not authenticated” despite a good-looking profile is an environment variable overriding your profile inside the Poetry environment. Let’s verify what the CLI actually sees in the same Poetry context and pinpoint the override: - Show the active profile and resolved config (this reveals env var precedence):
Copy code
poetry 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:
Copy code
poetry run env | grep PREFECT_
- Windows (PowerShell):
Copy code
poetry run powershell -NoProfile -Command "gci env:PREFECT_*"
- Quick Cloud checks:
Copy code
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:
Copy code
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:
Copy code
PREFECT_LOGGING_LEVEL=DEBUG poetry run prefect <your-command>
With that, I can zero in on the cause quickly.
j
I had an override env value!