Mendlark / Guides

Supabase Realtime not working (no changes received): how to fix it

Your chat, live dashboard or notification badge is meant to update on its own, but nothing happens until you refresh. There is no error in the console. The code calls supabase.channel(...).on('postgres_changes', ...).subscribe() and the callback simply never runs. Almost always, one of a few settings is stopping the changes from reaching the browser.

Stuck on this? Get it fixed for €49.

Fixed in 48 hours or you don't pay. Launch deal for the first 5 customers (normally €79). You get the tested fix as a pull request, so nothing changes until you merge it.

Get it fixed for €49

1. Check the subscription status first

Pass a callback to subscribe() so you can see what happened:

const channel = supabase
  .channel('messages-room')
  .on('postgres_changes',
      { event: '*', schema: 'public', table: 'messages' },
      (payload) => console.log('change', payload))
  .subscribe((status, err) => console.log('realtime', status, err));

SUBSCRIBED means the connection is fine and the problem is in steps 2 to 5. CHANNEL_ERROR or TIMED_OUT means the connection itself failed: check the URL and key, your network, and that you are not opening hundreds of channels (step 6).

2. Turn Realtime on for the table

Supabase only sends changes for tables that are in the supabase_realtime publication, and new tables are not in it by default. In the dashboard, open the table and switch on Realtime (or go to Database → Publications). Or run this in the SQL editor:

alter publication supabase_realtime add table public.messages;

If you have a test and a live project, do this in both. This is the most common cause when it "worked in the builder" but not after launch.

3. Row level security has to let the user see the row

Realtime respects your RLS policies. A user only receives a change if a select policy would let them read that row. If your policy is for signed-in users but the page subscribes before login, or uses the anon key with no session, you get SUBSCRIBED and then silence. Test by reading the same rows with a normal select as that user. If that returns nothing, see empty data with no error. Do not fix it by turning RLS off.

4. Give Realtime the user's token

supabase-js normally passes the signed-in session to Realtime. If you subscribe before the session has loaded, or you create the client with a custom token, the channel may connect as anonymous. Subscribe after sign-in, or set the token once you have it:

const { data: { session } } = await supabase.auth.getSession();
if (session) supabase.realtime.setAuth(session.access_token);

5. Filters and DELETE events

A filter must use the exact column name and PostgREST style syntax, for example filter: 'room_id=eq.' + roomId. A typo, a wrong value type, or an undefined roomId quietly matches nothing. Filters do not apply to DELETE events. With RLS on, a DELETE payload only includes the primary key in old. If you need the other old values, run:

alter table public.messages replica identity full;

6. React subscribes twice, or never cleans up

In React, put the subscription in useEffect and remove it in the cleanup. Otherwise Strict Mode, page changes and re-renders open extra channels, which can hit connection limits and show duplicate events:

useEffect(() => {
  const channel = supabase.channel('messages-' + roomId)
    .on('postgres_changes',
        { event: 'INSERT', schema: 'public', table: 'messages', filter: 'room_id=eq.' + roomId },
        (p) => setMessages((m) => [...m, p.new]))
    .subscribe();
  return () => { supabase.removeChannel(channel); };
}, [roomId]);

Quick checklist

  • Status callback shows SUBSCRIBED
  • Table is in the supabase_realtime publication in the live project
  • A select policy lets this user read the rows
  • Subscription starts after the session is loaded
  • Filter column and value are right; DELETE handled separately
  • Channel removed in the useEffect cleanup

Stuck on this? Get it fixed for €49.

Fixed in 48 hours or you don't pay. Launch deal for the first 5 customers (normally €79). You get the tested fix as a pull request, so nothing changes until you merge it.

Get it fixed for €49

Still stuck?

Mendlark fixes this kind of problem for a fixed €49 (launch price, normally €79). We agree the problem first, test the fix and send it as a pull request, so nothing changes in your app until you merge it. If we can't fix it, you don't pay. Get the €49 fix, or start with a free scan.

Not sure what else is wrong? Paste your app link into the free instant check and get a plain-English list of problems in seconds.