Nathan Oldakowski
08/28/2025, 7:51 PMwebsockets.exceptions.ConnectionClosedError: received 1002 (protocol error);
then sent 1002 (protocol error)
Marvin
08/28/2025, 7:51 PMMarvin
08/28/2025, 7:54 PMprefect config view --show-sources | grep PREFECT_API_URL
- Ensure it points to the API endpoint (e.g., Cloud: https://api.prefect.cloud/... not the UI URL) and has the correct scheme (https/wss).
- Try a minimal CLI creation to isolate UI/websocket involvement:
prefect work-pool create "test-proc-pool" --type process --paused
If this works, but the UI fails, it’s likely a websocket or proxy config issue.
- If you’re behind a proxy/reverse proxy/load balancer:
- Ensure websocket pass-through is configured (Upgrade/Connection headers preserved, HTTP/1.1 used).
- NGINX example:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s; # optional, but helpful
- For ALB/ELB/Cloudflare/Traefik: verify websocket support is enabled and timeouts aren’t overly aggressive. Many corporate proxies doing SSL inspection can break wss; you may need to trust the intercepting CA (e.g., via SSL_CERT_FILE) or bypass inspection for the API host.
- Network basics:
- Make sure outbound wss traffic is allowed to your Prefect API host.
- Check for clock skew on the client machine (large skew can break auth and cause immediate disconnects).
- If environment proxies are set, ensure `HTTPS_PROXY`/`NO_PROXY` are correct for the API host.
- Turn on debug logs to capture more detail:
PREFECT_LOGGING_LEVEL=DEBUG prefect work-pool create "test-proc-pool" --type process --paused
Also check server logs if self-hosting for any handshake/400 errors at the websocket endpoint.
If you can share:
- Prefect version (client and server, if self-hosted)
- Cloud vs self-hosted
- The exact command or UI path you used
- Whether there’s a proxy/load balancer in front of the API (and which one)
- A slightly longer snippet of the traceback or any server logs around the error
…I can help pinpoint the cause.
Helpful references:
- Troubleshoot Prefect Cloud connections
- Create a work pool (API reference)
Side note: I couldn’t find an open Prefect issue specifically tied to “1002 protocol error when creating work pools,” which further suggests an environment/proxy misconfiguration rather than a Prefect bug.