Madushan Pathirana
10/02/2025, 1:27 PMMarvin
10/02/2025, 1:27 PMMarvin
10/02/2025, 1:32 PMPREFECT_API_URL
and PREFECT_API_KEY
per environment, then switch with a flag or an env var.
Quick setup
1) Create a “remote” profile (points to your self-hosted server)
prefect profile create remote
prefect profile use remote
prefect config set PREFECT_API_URL=https://<your-remote-host-or-domain>/api PREFECT_API_KEY=<your-key>
2) Create a “local” profile (points to a local server if you run one)
prefect profile create local
prefect profile use local
prefect config set PREFECT_API_URL=<http://127.0.0.1:4200/api>
# If your local server has no auth:
prefect config unset PREFECT_API_KEY
How to switch without hassle
- For a single command, use the CLI flag:
prefect --profile remote work-pool ls
prefect --profile local server start
prefect --profile local deploy
- For a whole shell/session, use an env var:
PREFECT_PROFILE=remote python flow.py
PREFECT_PROFILE=local python flow.py
(Windows PowerShell: $env:PREFECT_PROFILE = "remote"
)
- Or set the default once and forget it:
prefect profile use remote
# later
prefect profile use local
Helpful commands
- List profiles: prefect profile ls
- Inspect current profile settings: prefect profile inspect
- View the resolved config: prefect config view
Notes for your setup
- Don’t hardcode API URLs in code; rely on the active profile and let Prefect’s client pick it up automatically.
- You can keep your ECS work pool for remote runs; to test locally, either:
- Run the flow directly (no server needed): python your_flow.py
- Or connect a local process worker to your remote server by using the remote
profile, then start a local “process” worker and run against the same work pool.
Docs
- Profiles and settings in Prefect 3.x: Settings and profiles
If you share your current PREFECT_API_URL
for the remote server, I can give you the exact commands with your values filled in.