Pradana Adnyana
11/21/2025, 2:11 AMMarvin
11/21/2025, 2:11 AMMarvin
11/21/2025, 2:15 AMexport PREFECT_SERVER_API_AUTH_STRING="admin:supersecret"
prefect server start
2) Configure clients (CLI, workers, flows) to connect with auth
- Point to your server and pass the same auth string:
export PREFECT_API_URL="<http://your-prefect-host:4200/api>"
export PREFECT_API_AUTH_STRING="admin:supersecret"
- Or set via Prefect config:
prefect config set PREFECT_API_URL="<http://your-prefect-host:4200/api>"
prefect config set PREFECT_API_AUTH_STRING="admin:supersecret"
- Then your CLI and workers will work as usual, e.g.:
prefect worker start --pool my-pool
3) Programmatic usage (Python)
- You can rely on the env vars above or pass explicitly:
from prefect import get_client
async def main():
async with get_client(
api="<http://your-prefect-host:4200/api>",
auth_string="admin:supersecret",
) as client:
await client.read_healthcheck()
Notes
- If you previously used Prefect Cloud, make sure any PREFECT_API_KEY isn’t interfering; for self-hosted, PREFECT_API_AUTH_STRING is what’s used.
- If your API is behind a reverse proxy, ensure it forwards the Authorization header to Prefect.
Helpful docs:
- Security settings (auth)
- API client
- Self-hosting Prefect
If you can share how you’re connecting (CLI, worker, Python code, Kubernetes, etc.), I can tailor the exact steps and env/manifest examples for your setup.