<@ULVA73B9P> `Exception: Unable to authenticate to...
# marvin-ai
l
@Marvin
Exception: Unable to authenticate to the event stream. Please ensure the provided auth_token you are using is valid for this environment.
workpool connection issue with prefect server
m
thought for 145.2 seconds
That error usually means your worker is connecting to a self‑hosted Prefect Server that requires basic auth for the event stream, but the worker isn’t sending matching credentials. Quick checklist (Prefect 3.x): 1) On the server: did you set
PREFECT_SERVER_API_AUTH_STRING
(e.g.,
admin:pass
)? If yes, the worker must use the same value via
PREFECT_API_AUTH_STRING
. 2) On the worker: - Point to your server API (must include
/api
) - Provide the matching auth string - Make sure you’re not setting a
PREFECT_API_KEY
(that’s only for Prefect Cloud) Example worker env:
Copy code
export PREFECT_API_URL="http://<your-server-host>:4200/api"
export PREFECT_API_AUTH_STRING="admin:pass"   # must match server's PREFECT_SERVER_API_AUTH_STRING
unset PREFECT_API_KEY                         # ensure Cloud key is not set
prefect worker start --pool <your-work-pool>
If you’re behind a reverse proxy (nginx, etc.), ensure WebSocket upgrades are allowed and headers aren’t stripped: - Forward `Upgrade`/`Connection` headers - Preserve WebSocket subprotocols (Prefect uses one during handshake) Debugging tips: - Enable verbose logs:
export PREFECT_DEBUG_MODE=1
and retry the worker - Verify server health:
curl -I http://<your-server-host>:4200/api/health
- Confirm env on each side: - Server:
echo $PREFECT_SERVER_API_AUTH_STRING
- Worker:
echo $PREFECT_API_URL
and
echo $PREFECT_API_AUTH_STRING
If this doesn’t resolve it, can you share: -
prefect version
- How you start the server (and whether
PREFECT_SERVER_API_AUTH_STRING
is set) - The
PREFECT_API_URL
you’re using on the worker - Any reverse proxy in front of the server Helpful docs: - Prefect settings - Work pools and workers - Self‑hosting Prefect Server
l
Why is prefect version
prefect:3.4.6-python3.12
requiring auth in the the schema server