I have a webserver running on an EC2 instance behind an AWS load balancer under a custom domain for using https.

Curl requests to the webserver work as expected, including over https. But establishing a websocket connection fails with the following error (in Chrome):

WebSocket connection to 'wss://sub.foo.com/' failed: Unknown reason

While this is a cryptic error message, my guess is that this has to do with AWS, because:

  • Establishing the socket with the server running on localhost works fine
  • Establishing the socket with the server running on AWS by bypassing the load balancer works fine

I use Clojure's http-kit for the webserver, but suspect it doesn't matter.

Amazon says its load balancers support websockets, so what am I doing wrong?

  • Have you opened the port on the load balancer?
    – LTPCGO
    Jan 3, 2020 at 23:24
  • I think so. The webserver's port is 8080 and that's where the load balancer redirects. That's why the other curl requests to other paths work. Jan 3, 2020 at 23:50
  • According to Google, the "wss" protocol defaults to port 443. Make sure you have port 443 opened on the security group for the load balancer and the instance, and that the load balancer is configured appropriately. If you hvae your URL above incorrect and meant to write "wss://sub.foo.com:8080/" please edit your question
    – Tim
    Jan 4, 2020 at 0:53
  • @Tim The security group accepts port 443. The load balancer listens on 443 and then redirects to my server on port 8080. Otherwise the curled https requests wouldn't work. For example, I can curl https://sub.foo.com/bar just fine. That leads me to believe the security group, load balancer and certificate are all set up correctly. Do you agree? Jan 4, 2020 at 3:23

1 Answer 1


This ended up being something completely unrelated: a browser extension. The uBlock Origin browser extension seems to not like secure websocket connections being made across domains (in this case, from localhost to my server on AWS behind my custom domain as I was testing).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.