Pradana Adnyana
11/21/2025, 1:05 AMMarvin
11/21/2025, 1:05 AMMarvin
11/21/2025, 1:10 AM/api endpoint via PREFECT_API_URL.
Quick start:
1) Start your self-hosted server
prefect server start
# UI at <http://127.0.0.1:4200>, API at <http://127.0.0.1:4200/api>
2) Point Prefect to your server
- One-off for current shell:
export PREFECT_API_URL="<http://127.0.0.1:4200/api>"
- Or persist it in a profile:
prefect profile create self-hosted
prefect profile use self-hosted
prefect config set PREFECT_API_URL="<http://127.0.0.1:4200/api>"
3) Verify the connection
prefect config view --show-sources
prefect flow ls
Workers pick it up the same way:
# Using active profile value
prefect worker start -p my-pool
# Or override inline
PREFECT_API_URL="<http://server:4200/api>" prefect worker start -p my-pool
Python example:
from prefect.client.orchestration import get_client
import asyncio
async def main():
async with get_client() as client:
flows = await client.read_flows()
print(f"Found {len(flows)} flows")
asyncio.run(main())
Tip for containers: inside Docker/Compose/K8s, don’t use localhost. Use the service DNS name:
# docker-compose example
environment:
PREFECT_API_URL: <http://prefect-server:4200/api>
Troubleshooting:
- “No Prefect API URL provided”: set it with prefect config set PREFECT_API_URL="http://<host>:4200/api" and re-run prefect config view --show-sources.
- Connection issues: ensure the server is running and reachable from the client/worker host and port.
Would you share a bit more about your setup?
- Prefect version (2.x or 3.x)?
- Where is your server running (local, Docker, Kubernetes, remote VM)?
- Are you connecting from your laptop, a container, or another machine?