I can't connect to the Prefect API - how to troubleshoot PREFECT_API_URL connection issues?

CLI

When you try to connect to a different PREFECT_API_URL e.g. by switching profile, Prefect will give you a warning it it cannot reach the API set in your profile (you can inspect this configuration in ~/.prefect/profiles.toml)

prefect profile use dev

image

UI warnings

When your active profile points to a Cloud workspace, but you are trying to connect to a local Orion API, the UI will also give you a warning.

[profiles.default]
PREFECT_API_URL = "http://127.0.0.1:4200/api"

[profiles.dev]
PREFECT_API_URL = "https://api.prefect.cloud/api/accounts/xxx/workspaces/yyy"

Switching the profile to default (pointing to a local API) and refreshing the UI should solve the issue:

prefect profile use default