Skip to content

Security basics

Supabase Realtime CHANNEL_ERROR: why a subscription gets nothing

Supabase Realtime CHANNEL_ERROR, or no events at all: usually a rule doing its job. How to read the reason and fix it without opening your data.

Vlad Tkachenko11 min read
A wall of pigeonholes with letters in most slots and one empty slot outlined in teal. In front, a letter sealed with a lock.

In short

  • Supabase Realtime CHANNEL_ERROR means the server turned your channel down, and the second argument of the subscribe callback carries its reason. "Unauthorized" on a private channel means no rule lets this user read the topic.
  • SUBSCRIBED with nothing arriving is a different problem. Supabase's own troubleshooting page names Row Level Security as the most common cause: a change only reaches subscribers who are allowed to read that row.
  • The quick fixes work by checking nobody. Anyone holding the key in your app can read and post on a public channel, and a rule that lets everyone receive every change lets them read every row as well. Write the rule for the people who belong.

You built a chat, a live order list or a notification bell with Lovable, Bolt, v0, Cursor, Claude Code or Replit. It worked in the preview. On the live app, new messages only show up when somebody refreshes the page. The browser console says CHANNEL_ERROR from Supabase Realtime, or it says SUBSCRIBED and then nothing at all.

There are three quick ways to make it go away: drop private: true from the channel, add a rule that lets everyone read the table, or switch Row Level Security off. Each of them works because it stops checking who is listening. Supabase's own troubleshooting page for silent subscriptions tells you to check Row Level Security early, and calls it "the single biggest source of 'silently missing' events, by a wide margin". The silence is usually a rule doing what you asked it to do.

Picture Realtime as the mail room of your app's building. Your app walks up to the desk and asks for a pigeonhole on a channel. The desk can say no, and that refusal is CHANNEL_ERROR. If it says yes, you get SUBSCRIBED and a pigeonhole. From then on every change in your database is a letter, and the clerk checks your rules before putting it into anybody's pigeonhole. A letter you may not read never goes in, and nobody leaves a note to say so.

What does CHANNEL_ERROR mean in Supabase Realtime?

It means Realtime turned your channel down, either when your app tried to join it or after it had joined. The reason is in the callback's second argument.

subscribe() in Supabase's JavaScript client reports one of four statuses: SUBSCRIBED, TIMED_OUT, CLOSED and CHANNEL_ERROR. When the server refuses a join, the client turns the server's reply into an Error and passes it as the second argument. Code that logs only the first sees the word and never the reason, so log both:

supabase
  .channel('room-1', { config: { private: true } })
  .on('broadcast', { event: 'message' }, (payload) => console.log(payload))
  .subscribe((status, err) => {
    console.log(status, err)
  })

With err logged, a bare CHANNEL_ERROR becomes a sentence: Unauthorized: You do not have permissions to read from this Channel topic: followed by your channel's name. The word before the colon is the server's code for the reason. The client's own source asks you to log the whole error rather than its message, because the cause inside it often holds the detail.

TIMED_OUT is a different failure: the join got no answer in time. CLOSED means the channel was shut down. Supabase's page draws the same line: a channel stuck at CHANNEL_ERROR "is a different problem than one that connects fine but never fires".

CHANNEL_ERROR is the desk refusing you a pigeonhole. SUBSCRIBED with no events is a pigeonhole the rules keep empty, and nothing tells you so.

Which reason did Realtime give?

Read the code before the colon. These five come from the Realtime server's own source, and only the first one is about your rules.

The message starts withWhat happenedWhere to look
UnauthorizedA private channel, and no rule on realtime.messages lets this user read the topic. A rule that fails with an error gets the same message.The next section
PrivateOnlyAllow public access is off in Realtime Settings, and the channel was joined without private: true.Add private: true and a rule for the topic
InvalidJWTTokenThe sign-in token your app sent has expired, or lacks the role and exp it needs.How your app signs users in
UnableToConnectToProjectRealtime could not reach your database.Your project's status in the Supabase dashboard
ConnectionRateLimitReached or JoinsRateLimitReachedToo many connected clients, or too many joins in a second, for the project's Realtime limits.Supabase's Realtime limits for your plan

Unauthorized on a private channel: no rule lets this user in

It means the desk checked your rules and found none that lets this user read the topic. That is Realtime Authorization doing its job.

A channel opened with private: true is checked against Row Level Security policies, the rules in your database that decide who may read or write what. For Realtime they sit on a table Supabase keeps for the purpose, realtime.messages. The server lets the join through only when a rule lets the user read the topic's broadcasts or its presence list, and answers everything else with the Unauthorized message.

Supabase works out what a user may do when they join, from your rules, the sign-in token your app sent and the channel's name. That leaves three ways to get the message:

  • There is no rule for this topic yet. A private channel lets nobody in until one exists.
  • The channel joined before sign-in finished. The token then said this was a visitor with no login, and a rule written to authenticated does not match one. Supabase recalculates permissions when your app sends Realtime a new token.
  • The rule itself fails. The server answers a policy that errors with the same Unauthorized text.

The fix is a rule for the people who belong in the channel. This is Supabase's own example, which lets a signed-in user in when your table lists them as a member of that room:

create policy "authenticated can receive broadcast"
on realtime.messages
for select
to authenticated
using (
  exists (
    select user_id
    from rooms_users
    where user_id = (select auth.uid())
      and room_topic = (select realtime.topic())
      and realtime.messages.extension in ('broadcast')
  )
);

realtime.topic() returns the name of the channel the user is joining. Your tables will have their own names, and writing a rule that compares the signed-in user to a row works the same way here as on any other table.

The change that makes the error vanish instead is deleting private: true. A public channel runs no check at all. Supabase's settings page says what that means while Allow public access is on, which it is by default: "anyone holding your project's anon key can subscribe to and broadcast on any public channel". The anon key is in every visitor's browser, and is meant to be. Anyone who reads the channel's name out of your app's code can listen to it and post into it. In the mail room, the desk has been swapped for a notice board in the lobby.

Supabase's advice for private channels is the opposite switch. Turn Allow public access off in Realtime Settings, and a channel joined without private: true is refused with PrivateOnly instead of being let in unchecked. Supabase warns that every change on that screen disconnects all your connected clients, so make it when you are ready to test.

Supabase Realtime not working, with no error: is a rule hiding the rows?

Usually, yes. Supabase's troubleshooting page for Postgres Changes calls Row Level Security the most common cause, and the one that wastes the most time, "because nothing errors".

Postgres Changes is the Realtime feature that sends your app a message when a row is inserted, updated or deleted. Supabase's documentation says that on a table with RLS, "database records are sent only to clients who are allowed to read them based on your RLS policies". The clerk reads every letter against the rules for each pigeonhole and drops the ones that fail, without a note. Your SUBSCRIBED was true. In Supabase's words, it "only means the WebSocket connected. It says nothing about whether that client is allowed to see the data."

Supabase's test is to ask for the same row the ordinary way, signed in as the same user:

const { data, error } = await supabase
  .from('messages')
  .select('*')
  .eq('id', idOfTheRowThatChanged)

console.log({ data, error })

An empty data with no error is your answer. The rule hides this row from this user, and Realtime hides its changes for the same reason. One case catches people out on updates: Supabase says the rule "generally has to allow both the old and new row state", so a row that moves out of what the user may see can lose its update on the way.

The quick fix that opens the table

A rule that lets everyone read the table, or Row Level Security switched off, makes every change arrive, because nobody is checked any more. The same rows are then open to every request made with your app's key.

Supabase's troubleshooting page says "Realtime enforces RLS the same way a normal query would". Postgres Changes has no rules of its own. The policy that decides which changes reach a subscriber is the policy that decides which rows your app's key gets back from Supabase's API. So a using (true) rule written for visitors with no login, to get a live feed moving, is also a read of every row in the table for anyone who copies the key out of your app. Switching RLS off for the table hands over the same rows with no rule at all.

Realtime reads the same rule as every other request. A rule opened for the live feed opens the table to anyone holding the key in your app.

The fix that keeps the feed and the table closed is a rule for the people who should see the rows. Supabase's own example lets a user see the messages in rooms they belong to:

create policy "Users can view messages in their rooms"
on messages for select
using (
  exists (
    select 1 from room_members
    where room_members.room_id = messages.room_id
      and room_members.user_id = auth.uid()
  )
);

Then run the select test above twice: as a user who belongs in the room, who should get the row and its live changes, and as one who does not, who should get neither. If a builder wrote the rule for you, read it back and look for a bare true, because a rule can be switched on and still let everyone in.

Whether a table answers a visitor with no login can also be seen from outside. Our free scan asks each table your app names how many rows a visitor with no login can count, reads only the number, and takes about 20 seconds with no account: scan your app.

When the rule is fine and nothing arrives

Then look at four of the other causes on Supabase's troubleshooting page. The first is easy to miss on a table created recently.

  1. The table is not in the supabase_realtime publication. Realtime only watches tables added to it, and Supabase notes that "creating the table and enabling Realtime on it are two separate steps". Check with select * from pg_publication_tables where pubname = 'supabase_realtime';, then add a missing table with alter publication supabase_realtime add table messages; or its toggle under Database, then Publications.
  2. The filter is written like code. Realtime filters take the shape column=operator.value, so room_id=eq.abc123 and never room_id = abc123. The table name has to match exactly, including case.
  3. An old channel is still listening. A React component that subscribes and never calls supabase.removeChannel(channel) when it goes away leaves the old subscription running against the previous room. Supabase calls this "almost always a React/Next.js problem".
  4. The change was written the instant SUBSCRIBED arrived. Supabase describes a gap between the client reporting SUBSCRIBED and the database feed being ready, and a write made inside it can be missed. It shows up mostly in automated tests.

The same page says Realtime does not guarantee every message arrives. When a missed update matters, use the event as a signal to fetch the latest rows.

Keeping the rule you wrote today

Two things can still change after today. A later edit can loosen the rule you just wrote, the way a quick fix for a silent feed would, and a loosened rule can let somebody change rows they should never have reached.

Reeve Monitor keeps checking from outside:

  • the full security check every hour, including how many rows a visitor with no login can count in the tables your app names
  • an alert the day a re-scan grades your app lower than the one before
  • whether the app is up, every 60 seconds

See what Monitor checks

Reeve Care keeps a copy of your Supabase database:

  • an encrypted copy on a schedule, on Reeve's own storage in the EU, outside your Supabase account
  • each copy verified before it counts, by counting the rows in every table
  • your uploaded files as well, once you connect a Storage credential
  • a one-click restore, with a safety copy of the current state taken first
  • everything Monitor does

See what Care keeps

The free scan shows what a visitor with no login can count in your tables today. About 20 seconds, and no account.

Scan your app free in 20 seconds

What to do now

What to do

  • Log the second argument of the subscribe callback. The word before the colon is Realtime's reason.
  • On Unauthorized, write a policy on realtime.messages for the users who belong in the topic, and join the channel after sign-in has finished.
  • On SUBSCRIBED and silence, run the same select as the same user. An empty answer means the rule is hiding the row.
  • Fix it with a rule for the people who should see the rows, never with using (true), RLS switched off or a public channel.
  • Once your channels are private, turn Allow public access off in Realtime Settings.
  • Check the table is in the supabase_realtime publication and the filter reads column=eq.value.

If you are not sure which of your tables a stranger can read today, scan your app and start with the one your live feed reads from.

FAQ

What does CHANNEL_ERROR mean in Supabase Realtime?

Realtime turned your app's channel down, either when it tried to join or after it had joined. The second argument of the subscribe callback is an Error whose message is the server's reason, such as "Unauthorized: You do not have permissions to read from this Channel topic". Log it with console.log(status, err) and read the word before the colon.

My Supabase Realtime subscription says SUBSCRIBED but no events arrive. Why?

SUBSCRIBED only says the connection was made. Supabase's troubleshooting page names Row Level Security as the most common cause of silence, because a change is sent only to subscribers allowed to read that row. Run the same select as the same signed-in user. An empty answer means the rule is what stops the event.

Can I remove private: true to get rid of the Unauthorized error?

The error goes away because a public channel runs no check at all. Supabase's settings page says that while public access is allowed, anyone holding your project's anon key can subscribe to and broadcast on any public channel, and that key ships inside your app. Keep the channel private and write a policy on realtime.messages for the users who belong in it.

Do I have to turn off RLS for Supabase Realtime to work?

No. Realtime applies your Row Level Security rules the same way an ordinary query does, as the signed-in user. Switching them off makes changes arrive because every visitor can now read every row, through the API as well as through Realtime. Write a select policy for the users who should receive the changes.

What does "PrivateOnly: This project only allows private channels" mean?

Allow public access is switched off in your project's Realtime Settings, and your code joined a channel without private: true. Add config: { private: true } to the channel and a policy on realtime.messages for the users who should read it. That is how Supabase says to enforce private channels.

Written by

Vlad Tkachenko

Founder, Reeve

I spend my time looking at apps built with Lovable, Bolt, v0, Cursor and Replit, and at the short list of mistakes that keep turning up in them.

More about the author

Read next

All articles

Back up your Supabase database before your next change

Reeve keeps an encrypted copy on a schedule and restores it for you if something breaks.

See Supabase backups

Automated external check, not a full audit. Absence of findings is not a guarantee of safety.