Phoenix Livewview - websocket connection fails

I have a small app deployed at for playing around with Elixir/Phoenix/LiveView etc.

The main page I converted to a LiveView - though it doesn’t do anything “LiveView-specific” just yet.

When deployed on, websockets are broken:

WebSocket connection to 'wss://' failed: 

This only happens when deployed to, I am unable to reproduce this issue locally.

I’m new to LiveView, and surely just missing something straightforward.

Thanks for the help!

What is the value if your check_origin config in config/runtime.exs. By default, we ensure the websocket connections match the URL host of the endpoint. For recent phoenix projects this is usually set to the PHX_HOST environment variable which is configured in your fly.toml. My guess is this value is the original domain, but needs to be changed to your domain.

Sure enough, that did it.


Errr actually you were proposing something slightly different, let me do that.

Perfect. Thanks again.

Great! For posterity for you and others, you can also do check_origin: :conn, which will allow any x-forwarded-for host. This is convenient if you have multiple domains that you don’t want to list explicitly, but can only be used if you are behind a proxy such that you can trust x-forwarded wasn’t set by the client. Fly sets this header so check_origin: :conn is a good option, but you’ll still want to configure your endpoint’t :url (which is based on PHX_HOST by default) for link/url generation.

1 Like