Skip to content
Latchkey

Phoenix Channels "no connection to the server" in CI

The Phoenix JS client refuses to join a channel while its underlying Socket is not connected, reporting "unable to join, no connection to the server". The Socket transport never opened, so no join can be sent.

What this error means

A browser or JS test logs "unable to join, no connection to the server" when calling channel.join(), because socket.connect() did not establish the WebSocket first.

Phoenix
unable to join, no connection to the server
    at Channel.join (phoenix.js:...)

Common causes

join() called before the socket connected

The test joined a channel immediately after constructing the Socket, before the WebSocket transport had opened.

The endpoint or WebSocket route is unreachable

A wrong socket URL, a server not yet listening, or a blocked /socket/websocket route means the transport never opens.

How to fix it

Connect the socket and wait for open

  1. Call socket.connect() and wait for the onOpen callback before joining.
  2. Confirm the socket URL matches the server endpoint route.
  3. Ensure the Phoenix server is listening before the test runs.
test.js
const socket = new Socket('/socket');
socket.onOpen(() => channel.join());
socket.connect();

Verify the socket endpoint

The URL must resolve to the server's socket route; a mismatch prevents the transport from opening.

test.js
const socket = new Socket('ws://localhost:4000/socket');

How to prevent it

  • Wait for socket onOpen before joining any channel.
  • Keep the client socket URL aligned with the endpoint route.
  • Ensure the Phoenix server is listening before browser tests run.

Frequently asked questions

What causes ""no connection to the server""?
The test joined a channel immediately after constructing the Socket, before the WebSocket transport had opened.
How do I fix "no connection to the server"?
Connect the socket and wait for open

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card