supabase-js: WebSocket connection failed on subscribing to realtime channel
Bug report
Describe the bug
I’m trying to use Supabase’s realtime updates locally, and I’m getting the following error
WebSocket connection to 'ws://localhost:54321/realtime/v1/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0' failed
To Reproduce
- Clone this repo https://github.com/skulltech/sample-realtime-app
- Run
yarn install
andsupabase start
, and thenyarn dev
to start the server. - Go to
http://localhost:3000
and check the console to see the above mentioned error. - The webapp has some basic functionality for writing and reading to database to make sure that the other Supabase functionalities are working as expected.
Expected behavior
No errors while subscribing to the realtime channel.
Screenshots

System information
- OS: macOS
- Browser: Chrome
- Version of supabase-js: 2.2.3
- Version of Node.js: v19.4.0
- Version of Supabase CLI: 1.29.2
- Version of Docker desktop for Mac: 4.15.0
Additional context
The same code seems to be working on production Supabase at app.supabase.com.
The same code was working before I updated my whole stack, i.e. updated Supabase CLI as well as @supabase/supabase-js, moved to Postgres v15 locally (i.e. in config.toml), from v14 previously, and ran brew upgrade which included updating docker desktop.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 9
- Comments: 23 (1 by maintainers)
I am having the same issue.
Fixed in
"@supabase/supabase-js": "2.4.0"
@skulltech @aerophobic@atanaskanchev I am having the same issues and I am using “@supabase/supabase-js”: “2.4.0”.
I continue to have this issue after running
brew upgrade supabase
followed bysupabase stop
andsupabase start
.Testing with:
@fbeutel how did you re-generate the JWT secret? Experiencing the same issue
We had the same issue, but it seemed like re-generating the JWT secret (and therefore changing the API keys) solved the problem…
Also have this issue:
supabase/postgres │ 15.1.0.117 │ - supabase/gotrue │ v2.99.0 │ - postgrest/postgrest │ v11.2.0 │ - supabase/realtime │ v2.10.1 │ - supabase/storage-api │ v0.40.4 │ - supabase/edge-runtime │ v1.20.2 │ - supabase/studio │ 20230921-d657f29 │ - supabase/postgres-meta │ v0.68.0 │ - supabase/logflare │ 1.4.0 │ - bitnami/pgbouncer │ 1.20.1-debian-11-r39 │ - darthsim/imgproxy │ v3.8.0 │ -
Error:
` WebSocket connection to 'ws://localhost:54321/realtime/v1/websocket?apikey={apiKey}&vsn=1.0.0: failed
` Code:
` const entriesChannel = supabase .channel(‘custom-all-channel’) .on(‘postgres_changes’, { event: ‘*’, schema: ‘public’, table: ‘entries’ }, (payload) => { console.log(‘Change received!’, payload); }) .subscribe();
`
dependencies:
"@supabase/auth-helpers-sveltekit": "^0.10.3", "@supabase/auth-ui-shared": "^0.1.8", "@supabase/auth-ui-svelte": "^0.2.7", "@supabase/supabase-js": "^2.38.1",
Supabase CLI: 1.106.1