Supabase Realtime not working: the channel says SUBSCRIBED but no changes arrive

By AI App Medic · Updated · Supabase · Realtime · RLS · Lovable

You asked Lovable, Bolt or Cursor for a live feature: new chat messages, an order status that updates on its own, a dashboard that refreshes. The code looks right. The console even prints SUBSCRIBED. Then you insert a row and nothing happens until you reload the page.

Realtime fails silently. There is no error when a table is not published or when RLS hides a row, the event just never arrives. Work through these checks in order. Most apps are fixed by the first two.

Step 0: log what the channel is doing

Many generated subscriptions call .subscribe() with no callback, so you never see a failure. Add one:

const channel = supabase
  .channel("orders-feed")
  .on(
    "postgres_changes",
    { event: "*", schema: "public", table: "orders" },
    function (payload) { console.log("change", payload); }
  )
  .subscribe(function (status, err) {
    console.log("realtime status", status, err);
  });

SUBSCRIBED means the WebSocket joined the channel. It says nothing about whether you are allowed to see any rows. CHANNEL_ERROR and TIMED_OUT come with an error you can read. CLOSED usually means your own code removed the channel, often a React cleanup running earlier than you expect.

Also note the channel name. Any string works except realtime, which is reserved.

Step 1: is the table in the publication?

Realtime does not watch every table. A table has to be added to the supabase_realtime publication. Creating a table and enabling Realtime on it are separate steps, and AI tools often do the first and forget the second, especially when a migration recreates the table. Check in the SQL Editor:

select schemaname, tablename
from pg_publication_tables
where pubname = 'supabase_realtime';

If your table is not listed:

alter publication supabase_realtime add table public.orders;

You can do the same under Database, Publications in the dashboard. Put the SQL in a migration so a fresh environment gets it too. If you drop and recreate the table, add it again.

Step 2: can this user select the row?

This is the most common cause and the one that wastes the most time. Realtime applies Row Level Security as the subscribing user. An insert or update event is only delivered if that user could select the new row. No matching policy, no event, no error.

Test it from the app with the same signed-in user, not in the SQL Editor, which runs as postgres and skips RLS:

const { data, error } = await supabase
  .from("orders")
  .select("*")
  .eq("id", idOfTheRowThatChanged);
console.log({ data, error });

An empty array means a policy is hiding the row. Add a select policy that matches what the user should see:

create policy "customers read own orders"
  on public.orders for select to authenticated
  using ((select auth.uid()) = customer_id);

For shared data like a chat room, the policy usually checks a membership table. Keep that subquery simple and indexed, because it runs for every subscriber on every change. If a policy on one table queries another table whose policy queries the first, you will hit the error covered in infinite recursion detected in policy.

Two details catch people with updates. The event can fail to arrive if the update moves the row out of what the policy allows, for example a policy that only shows status = 'open' rows and an update that sets closed. And a policy that relies on a column the update changes can behave differently for the old and new row. If deletes arrive but inserts and updates do not, you have confirmed it is RLS, since delete events are not filtered by RLS at all.

More background on empty results is in Lovable + Supabase RLS not working.

Step 3: does the role have a grant?

RLS only decides which rows a role sees. The role also needs a privilege on the table. Supabase stopped granting new public tables to anon and authenticated automatically in 2026, so a table created recently may have no grant at all. Normal queries then fail with permission denied for table, and Realtime just stays quiet. Add the grant for the role your subscribers use:

grant select on table public.orders to authenticated;

The full explanation is in Supabase permission denied for table. The same applies to tables in a schema other than public, which always need an explicit grant.

Step 4: subscribe after the session is ready

If the channel opens before the stored session has loaded, Realtime evaluates your policies as anon, and a policy that uses auth.uid() matches nothing. This happens on first page load in most generated apps, because the subscription sits in a top-level useEffect that runs immediately.

Open the channel only once you have a session, and open it again when the user changes:

const [session, setSession] = useState(null);

useEffect(function () {
  supabase.auth.getSession().then(function (res) { setSession(res.data.session); });
  const { data } = supabase.auth.onAuthStateChange(function (_event, s) { setSession(s); });
  return function () { data.subscription.unsubscribe(); };
}, []);

useEffect(function () {
  if (!session) return;
  const channel = supabase
    .channel("orders-" + session.user.id)
    .on(
      "postgres_changes",
      { event: "*", schema: "public", table: "orders", filter: "customer_id=eq." + session.user.id },
      function (payload) { applyChange(payload); }
    )
    .subscribe();
  return function () { supabase.removeChannel(channel); };
}, [session?.user?.id]);

If you manage tokens yourself, call supabase.realtime.setAuth(token) with the new access token so policies are checked against the current user. If the session cannot refresh at all, see Invalid Refresh Token: Refresh Token Not Found.

Step 5: check the filter

Remove the filter and use event: "*". If events now arrive, the filter is the problem. Filters use the PostgREST style, column=operator.value, for example room_id=eq.42, not room_id = 42. Supported operators are eq, neq, lt, lte, gt, gte and in, with up to 100 values for in. Delete events cannot be filtered. The table and schema names must match exactly, including case.

Step 6: stop stacking subscriptions

If you see tried to subscribe multiple times, or every event fires two or three times, the effect is creating a new channel on each render or never cleaning up. Every effect that subscribes must return a cleanup that calls supabase.removeChannel(channel), and the dependency array should hold stable values like an id, not whole objects. React Strict Mode mounts components twice in development, which makes a missing cleanup show up immediately.

Events arrive but the data is wrong

Prevention

Treat Realtime as part of the table definition. In the migration that creates a table you want live, include the grant, RLS, a select policy and the publication line. Test live features with two normal accounts in two browsers, not with your owner account. And keep the status callback logging in place, so the next silent failure tells you what happened.

FAQ

Why do I get DELETE events but not INSERT or UPDATE?

Delete events are not filtered by RLS, because Postgres cannot check a policy against a row that no longer exists. Insert and update events are only sent to subscribers who could select the row. If deletes arrive and inserts do not, RLS or a missing grant is blocking delivery.

Why is payload.old empty or only the id?

By default Postgres sends only the primary key for the old row. Set replica identity full on the table to get the full old row. On tables with RLS enabled, the old record still contains only the primary key, so do not build logic that depends on other old values.

Realtime works for me but not for my users. Why?

You are probably testing as the project owner or with policies that match your own rows. Test with a second normal account. Also check that the subscriber is signed in before the channel opens.

Should I use postgres_changes for a busy chat or live dashboard?

It works for small and medium apps. Each change is checked against every subscriber, so it gets slower as users grow. For high-traffic features, Supabase recommends Broadcast, including Broadcast triggered from the database.

Related guides