Craig Rose
03/26/2026, 4:50 AMMarvin
03/26/2026, 4:51 AMCraig Rose
03/26/2026, 4:54 AMMarvin
03/26/2026, 4:54 AMMarvin
03/26/2026, 4:59 AMPREFECT_SERVER_API_AUTH_STRING. Any client (workers, job containers, scripts) must send the matching PREFECT_API_AUTH_STRING.
You likely have one (or both) of these issues:
1) Token mismatch/missing
- Server has PREFECT_SERVER_API_AUTH_STRING set, but the job container does not have the matching PREFECT_API_AUTH_STRING.
2) Wrong API URL inside the container
- Inside the job container, PREFECT_API_URL is defaulting to <http://127.0.0.1:4200/api> (your logs show that), which is usually not the host server when running in Docker. Even if auth is fixed, the container should point at a reachable host address.
How to fix
Pick one of the two approaches below:
A) Keep auth enabled (recommended if you set it intentionally)
1. Confirm the server is started with an auth string:
- If you’re starting locally:
PREFECT_SERVER_API_AUTH_STRING="admin:password" prefect server start
2. Propagate the same auth string and a correct API URL to your job containers via the Docker work pool’s base job template (UI: Work Pools > your docker pool > Base job template > Edit):
- Add environment:
"env": {
"PREFECT_API_URL": "<http://host.docker.internal:4200/api>", // Mac/Windows
"PREFECT_API_AUTH_STRING": "admin:password"
}
- If you’re on Linux, replace the URL or add host mapping:
- Use the bridge gateway IP:
"env": {
"PREFECT_API_URL": "<http://172.17.0.1:4200/api>",
"PREFECT_API_AUTH_STRING": "admin:password"
}
- Or add an extra host mapping equivalent to --add-host=host.docker.internal:host-gateway in the base job template and keep host.docker.internal in the URL.
3. (Optional) Verify the pool config via CLI
prefect work-pool inspect "your-docker-pool" --output json
If needed, export, edit, and re-apply the template:
# edit docker.json to add env settings above
prefect work-pool update "your-docker-pool" --base-job-template docker.json
B) Disable auth (if you didn’t mean to enable it for local dev)
- Unset PREFECT_SERVER_API_AUTH_STRING and restart the server. Then you won’t need PREFECT_API_AUTH_STRING in the container.
- You still should set a correct PREFECT_API_URL inside the job container (see above) — don’t leave it at <http://127.0.0.1:4200/api> unless you’re using host networking.
Notes on API URL inside Docker
- Mac/Windows (Docker Desktop): <http://host.docker.internal:4200/api>
- Linux (default bridge): <http://172.17.0.1:4200/api> OR add a host-gateway mapping and use host.docker.internal
- If your Server is also running in Docker Compose on the same network, use the service name: e.g., <http://prefect-server:4200/api>
Why your container crashed
- The runner raises an exception when the auth handshake fails with the events service. Once you provide a valid PREFECT_API_AUTH_STRING (matching the server’s PREFECT_SERVER_API_AUTH_STRING) and a reachable PREFECT_API_URL, the flow should start and report events normally.
Docs and references
- Manage settings (including PREFECT_API_URL): Manage settings
- Security settings (Basic auth for self‑hosted: PREFECT_SERVER_API_AUTH_STRING and PREFECT_API_AUTH_STRING): Security settings
- Run Prefect Server in Docker: Server in DockerMarvin
03/26/2026, 4:59 AMPREFECT_SERVER_API_AUTH_STRING when starting the server? If so, what’s the value format (no need to share the secret itself)?
- Is your Server running on the host machine or in Docker Compose? If Compose, what’s the service name/network setup?Craig Rose
03/26/2026, 5:08 AMMarvin
03/26/2026, 5:08 AMMarvin
03/26/2026, 5:09 AMunset PREFECT_SERVER_API_AUTH_STRING
- PowerShell:
Remove-Item Env:PREFECT_SERVER_API_AUTH_STRING
- Windows CMD:
set PREFECT_SERVER_API_AUTH_STRING=
If you’re using Docker Compose, remove it from the service’s environment block (or set it to an empty string, which disables auth because it’s falsy):
services:
prefect-server:
environment:
# Remove this line entirely, or make it empty
# PREFECT_SERVER_API_AUTH_STRING:
Then restart the server container.
2) If you set it in a Prefect profile, unset it there too
- This restores the default (None) in the active profile:
prefect config unset PREFECT_SERVER_API_AUTH_STRING
Verify it’s gone
- Check the shell you’ll use to start the server:
- Mac/Linux:
echo $PREFECT_SERVER_API_AUTH_STRING
- PowerShell:
$Env:PREFECT_SERVER_API_AUTH_STRING
- And view Prefect’s profile settings:
prefect config view
Important: Restart the Prefect server after unsetting so it picks up the change.
Tip: If your job containers are still pointing at 127.0.0.1 from inside Docker, update PREFECT_API_URL too:
- Mac/Windows: <http://host.docker.internal:4200/api>
- Linux: <http://172.17.0.1:4200/api> (or add a host-gateway mapping and use host.docker.internal)
Docs for reference:
- Security settings (auth strings): Security settings
- Manage settings and profiles: Manage settings
If you clear that env var and restart the server, the websocket should accept connections without a token and your container should stop crashing.