Supabase empty array, 42501 or 401: one question splits them
By Christophe Paka · Facts checked on 23 October 2026
You made a table and added rows. The SQL Editor shows them all. Then your app asks for the same rows and gets a Supabase empty array: [], with no error. Readers on Reddit hit this so often that RLS returning empty arrays is one of the top beginner threads.
The common reaction is the worst one: switch Row Level Security (RLS) off to see if that helps. It does, and now anyone with your key can read every row.
The figure below splits the three first day failures with one question. Is there an error code? The answer points at a missing grant, a wrong key or a missing policy.

Use this diagram on your site
Free to share in your blog post, docs, course or slides, as long as the credit link stays. Paste the code below where the figure should go.
How to read this figure
Print the error first. The top box says the page shows nothing useful. Before you guess, read the error your app got back. A supabase-js call returns
{ data, error }:error.codeholds the code, such as 42501, anderror.messagethe words. If an AI tool wrote your app, ask it to show you both. The code alone decides your branch.Left branch: 42501 means a missing grant. The message reads permission denied for table. A grant is the Postgres statement that lets a role, such as
anon, touch a table at all. Grants are checked before policies, so no policy ever ran. The fix is one line:grant select on public.t to anon;Middle branch: 401 means the wrong key. A secret key sent from a browser answers 401 on purpose. The platform refuses it so the key cannot leak through your site. Put the key that begins
sb_publishable_in the client, and only that one. Then replace the secret key, since it was exposed.Right branch: an empty array means no policy. No error and
[]means the grant let the request in, but RLS let no rows out. Either no policy exists for this role and operation, or itsusingtest matched no row. Write the policy. For rows anyone may read, it endsfor select to anon using (true);. For private rows, the test must name the user.Read the band at the bottom. But it works in the SQL Editor. The editor runs as the postgres role, which has BYPASSRLS, so policies never apply there. Rows in the editor prove nothing about your app. Test with the publishable key instead.
Key takeaways
- Read the error code before you change anything: 42501 is a grant, 401 a key, an empty array a policy.
- Never switch RLS off to test; write or fix the policy instead.
- Prove each table as a stranger, with the publishable key and no user, not in the SQL Editor.
Try this: walk all three branches on one table
You need the SQL Editor, curl, your project URL and your publishable key. No AI tool? Paste each SQL line into the SQL Editor as it is.
- In the SQL Editor, create a table
composersand insert two rows. Turn RLS on withalter table public.composers enable row level security;and take the grant away withrevoke select on public.composers from anon;. - Ask the way your app asks:
curl 'https://<PROJECT_REF>.supabase.co/rest/v1/composers?select=*' -H "apikey: <PUBLISHABLE_KEY>". You get code 42501, permission denied for table: the left branch. - Run
grant select on public.composers to anon;and the same curl again. You get[]and no error: the right branch. - Add one policy:
create policy "public can read composers" on public.composers for select to anon using (true);and run curl a third time.
Expected result: The third call returns the two rows as JSON. Each step fixed one gate: first the grant, then the policy. RLS on with no policy is a safe start, not a finished state.
Questions readers ask
Why does my Supabase query return an empty array with no error?
RLS is on and no policy matched this role and operation. Either no policy exists for it, or the policy's using test filtered every row out. Write or fix the policy. The rows are still there; RLS only hides them from this role.
What does permission denied for table, error 42501, mean in Supabase?
The role has no grant on the table, so Postgres refused the request before any policy ran. Add the grant, such as grant select on public.instruments to anon;. A new table without a grant gives this error. Three schemas, three outcomes shows where grants fit.
Why does my query work in the SQL Editor but not in my app?
The SQL Editor runs as the postgres role, which skips every policy. Your app runs as anon or authenticated, so policies apply to it. Test the way the app asks, with curl and the publishable key, or with the Security Advisor in the dashboard.
What do I tell my AI tool for each error?
Give it the code and one line. For 42501: "add a grant for this role on this table." For 401: "use only the sb_publishable_ key in browser code, and replace the secret key." For an empty array: "write one policy per operation for this table, naming the role with to." Add to each: never switch RLS off.
Sources: Securing your API (Supabase docs); Tables and data (Supabase docs); Database advisors (Supabase docs).
This figure is from Supabase Made Crystal Clear, chapter 3.
The chapter builds the idea step by step, with recipes you can follow, a Try it to check yourself, and every source.
Get the book


