<@ULVA73B9P> getting this error when creating a ne...
# ask-marvin
n
@Marvin getting this error when creating a new work pool - any ideas on things to check?
websockets.exceptions.ConnectionClosedError: received 1002 (protocol error);
then sent 1002 (protocol error)
m
thought for 208.8 seconds
A 1002 “protocol error” on a websocket usually points to something interfering with the websocket handshake or frames (often a proxy/reverse proxy, load balancer, SSL inspection, or a mismatched URL). Creating a work pool itself is a simple REST call, but workers and parts of the UI use websockets; if a proxy is in the path, you can see this error during related calls. A few quick things to check: - Are you on Prefect Cloud or self-hosted Server? Which Prefect version? Where exactly do you see the error (CLI/worker logs/server logs/UI)? - Confirm your API URL: - Run:
Copy code
prefect 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:
Copy code
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:
Copy code
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:
Copy code
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.