Skip to content

Supabase Realtime WebSocket fails on localhost in @supabase/supabase-js@2.49.8 #1442

@paulbland

Description

@paulbland
  • I confirm this is a bug with Supabase, not my own application
  • I’ve searched the Docs, GitHub Discussions, and Discord

🔍 Describe the Bug

In version 2.49.8 of @supabase/supabase-js, Realtime WebSocket connections fail in local development with this error:

WebSocket connection to ‘wss://<id>.supabase.co/realtime/v1/websocket?apikey=<key>&vsn=1.0.0’ failed: WebSocket is closed before the connection is established.
  • ✅ The exact same code works in production
  • ✅ It also works locally when using 2.49.1 or 2.49.7
  • ❌ Fails consistently in local dev only when using 2.49.8 and 2.49.9

🧪 To Reproduce

  1. Subscribe to a postgres_changes channel in local dev:
supabase
  .channel("credits-updates")
  .on("postgres_changes", { event: "UPDATE", schema: "public", table: "user_profiles" }, () => {})
  .subscribe();
  1. Load the page in http://localhost:5173 (Vite + React app)
  2. Observe the error in console

✅ Expected Behavior

The WebSocket connection should succeed and subscribe to the channel, just as it does in:
• Production environment
• Local dev using versions before 2.49.8

🖥️ System Info
• OS: macOS Sequoia 15.5
• Browser: Chrome 137
• Node.js: 22.14.0
• Package: @supabase/supabase-js@2.49.8
• Framework: Vite + React
• Frontend served over: http://localhost:5173

💬 Additional Context

Downgrading to @supabase/supabase-js@2.49.1 or 2.49.7 fixes the issue.
The problem appears isolated to local dev environments using Vite, but the backend setup and keys are correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions