Fixes
Supabase errors and fixes
Sign-in and email problems, row level security, queries that return nothing, Edge Functions, storage and the database. Each page is checked against Supabase’s own docs and says what to try first.
32 Supabase fixes. Also see Supabase RLS policy checker, Supabase grants and RLS checker and Supabase RLS fix.
Guides to these errors in one place: Supabase Auth errors and Supabase database and Edge Function errors.
- Supabase setup questionHow do I get a Supabase staging environment and stop testing on production?Use Supabase Branching: a persistent branch for staging, or a preview branch for each pull request. A branch connected to GitHub builds its database structure from the migrations in your repository; every branch starts with no data by default and gets placeholder sign-in secrets. So get your schema into migrations first, then add a seed file and branch secrets. Watch the cost: branches bill by the hour and aren’t covered by the Spend Cap.
- Supabase StorageMy Supabase storage bucket is public. Are the files exposed?A public bucket skips access control for reading files: anyone with a file’s URL can open it. Uploads, deletes and moves are still checked by your policies. Keep public buckets for files meant to be public, move private files to a private bucket with row-level security policies, and serve them through signed URLs or signed-in downloads.
- Supabase RealtimeSupabase Realtime is subscribed, but no changes arriveFirst check the table is in the supabase_realtime publication, since Realtime ignores tables that aren’t. Then check row-level security: Realtime applies it as the subscribing user, so on a table with RLS it only sends changes that user is allowed to see, and SUBSCRIBED doesn’t mean they can. If events arrive but old values are empty, that’s replica identity. Last, check the table name, schema and filter in the subscription.
- Supabase databaseSupabase: too many connections, or remaining connection slots are reservedYour database has a connection limit set by its compute size, and something is opening more connections than it allows. In serverless or edge functions, connect through Supabase’s shared pooler in transaction mode, create the client once, and set its pool to 1 connection. If you’re already pooling and still at the limit, a larger compute size allows more connections.
- Supabase Auth session bugSupabase logs users out when they refresh the pageIn a Next.js or other server-rendered app, use the @supabase/ssr clients so the session lives in cookies, and add the middleware (proxy.ts on Next.js 16) that refreshes it on every request. In a browser-only app, create one Supabase client with persistSession on, and wait for the stored session to load before your route guard sends anyone to the login page.
- Supabase database errornew row violates row-level security policy for tableThe table has RLS on and no INSERT policy that this row passes. Add one whose WITH CHECK matches the row, usually user_id = auth.uid(), and make sure the insert sets user_id for a signed-in user. If you call .select() after the insert, or use upsert, the table also needs a SELECT policy the new row passes. Don’t fix it by turning RLS off.
- Supabase Auth email bugSupabase confirmation and reset emails link to localhost:3000Change the Site URL in Supabase under Authentication, URL Configuration, from http://localhost:3000 to your live address. Supabase uses it when your code doesn’t pass a redirect URL. If your code does pass one, that exact URL must also be on the Redirect URLs allow list.
- Supabase key leakMy Supabase service_role key is exposedTreat the key as compromised. Fix how it leaked first, or the new key leaks the same way. Then create a new secret key, replace the old one everywhere, confirm nothing still uses it, and retire the old key. If it was a legacy service_role key, also revoke the legacy JWT secret. If someone is actively using the leaked key, retire it right away and do the leak fix afterwards. Retiring legacy keys also switches off the anon key, so the site breaks until your apps move to a publishable key. Then check your Supabase logs and tables for changes you didn’t make.
- Supabase Auth email errorSupabase “email rate limit exceeded” on sign-upSupabase’s built-in email service is for trying things out. It only sends to members of your project’s team, and Supabase currently limits it to 2 messages an hour, a number it says can change without notice. Set up custom SMTP with an email provider. Supabase then starts you at 30 messages an hour, which you can raise on the Rate Limits page before a launch.
- Supabase Auth errorSupabase sign-in fails with “Email not confirmed”With Confirm Email on, which is the default on hosted Supabase projects, users have to click the link in the confirmation email before their first sign-in. If they never got the email, check sending first: the default email service allows 2 emails per hour on a best-effort basis, so set up custom SMTP for production. Make sure the link goes to your real site rather than localhost:3000, then resend the confirmation with supabase.auth.resend().
- Supabase Auth errorSupabase sign-up fails with “Database error saving new user”Supabase lists three common causes: a trigger or trigger function on auth.users that has an error, a constraint on auth.users that isn’t met, or Prisma breaking the permissions on that table. Open the Auth logs first, then the Postgres logs, for the exact error. A frequent one is a handle_new_user trigger inserting into a profiles table that doesn’t exist.
- Supabase Edge Functions errorSupabase: “Edge Function returned a non-2xx status code”Your function ran but returned an error status (4xx or 5xx). In supabase-js that is a FunctionsHttpError, and the function’s own error message is in error.context: read it with await error.context.json(). Then check the function’s logs in the Logs tab of the Supabase dashboard, fix what the function reports, and have it return a clear status code and message.
- Supabase Auth errorSupabase users logged out with “Invalid Refresh Token”Each Supabase refresh token can be exchanged only once, for a new access and refresh token pair. Reuse is allowed within a 10-second interval by default, or when the parent of the active token is used; otherwise Supabase treats the whole session as terminated and revokes all its refresh tokens. Look for two places refreshing with the same token, such as the server and the browser, or an app restoring an older saved session.
- Supabase Auth errorSupabase: “Email link is invalid or has expired” (otp_expired)Supabase says the most common cause is email prefetching: a mail client or security tool, such as Safe Links in Microsoft Defender for Office 365, opens the link to check it and uses up the one-time token. Stop the link from consuming the token: put the 6-digit code {{ .Token }} in the email template, or link to a page of your own where the user enters it.
- Supabase email problemWhy do my Supabase sign-up emails go to spam, and how do I fix it?Send through your own email provider (custom SMTP in Supabase, such as Resend or Twilio SendGrid) from your own domain, and verify that domain with the provider so SPF and DKIM pass. Add a DMARC record, starting with p=none, or edit the one you already have. Keep the From: address on the domain you verified, ideally the same domain as your website, and leave open and click tracking off for sign-up emails.
- Supabase project pausedMy Supabase project is paused and my app is downOpen the project in the Supabase dashboard and click Resume project. Supabase says a paused project can be restored for up to 1 year after it was paused. Once it’s back, check your tables and row counts and that the app connects again. For an app with real users, move the project to a paid plan: Supabase doesn’t pause paid projects.
- Supabase key questionIs it safe that my Supabase anon key is in my frontend code?Yes, if row-level security is on. Supabase calls the anon key the legacy version of the publishable key, which it says is safe to expose online, and anyone can read it in your code. Row-level security decides what that key can reach, so turn it on for every table and give each table policies. The key that must never be public is the secret or service_role key.
- Supabase security questionI turned on RLS in Supabase. Is my data safe now?Not necessarily. Turning on RLS is the first step, not the last. Check four things: that signed-out visitors don’t have permissions on tables they don’t need, that any view over a protected table follows the table’s rules, that no rule lets everyone read private data, and that the admin key (secret or service_role) never reaches the browser. Then test the rules by signing in as two different users.
- Supabase published app errorSupabase “TypeError: Failed to fetch” on a published appOpen the browser’s Network tab, reload, and look at the failed request. If its address contains undefined, the Supabase URL never reached the published build. If the address is right, check whether the project is paused, whether an Edge Function is failing its CORS check, and whether a browser extension is blocking the call.
- Supabase API errorSupabase “Could not find the table … in the schema cache” (PGRST205)Supabase’s API can’t see a table with that name. First check the table exists in the project your app’s URL points at, since a migration that never ran, or a staging project, would leave it missing. If it exists, reload the schema cache with NOTIFY pgrst, 'reload schema'; in the SQL Editor. If it lives outside the public schema, expose that schema or name it in the query.
- Supabase Auth errorSupabase “provider_disabled”: the sign-in provider is offEnable the provider on its page in the hosted project’s dashboard, with the client ID and secret from the provider. For local development, Supabase configures the provider in supabase/config.toml instead; Simon also restarts the local stack after editing it. For email or phone sign-up, check that those providers are on as well.
- Supabase Auth errorSupabase “Invalid login credentials” when users sign inCheck error.code. If it is invalid_credentials, Supabase doesn’t say which problem it is: it can mean a wrong password, no account with that email, or an account that only signs in through a social login. Send a password reset if the user has a password account, or point them to the button they signed up with. If the code is email_not_confirmed, it’s a different problem.
- Supabase query problemSupabase select returns an empty array, but the data is thereCheck that the table has a select policy: with RLS on and no policy, the API returns no data to the browser key. Then check who the request runs as: a signed-out user or an expired session matches no rows in a policy based on auth.uid(). If you get error 42501 instead of an empty array, the role is missing a grant.
- Supabase Auth errorSupabase: “Signups not allowed for this instance”In the Supabase dashboard, open the Authentication settings for sign-ups and turn Allow new users to sign up back on for the project your production app uses. For email sign-ups, check the email provider is enabled too. When you run Supabase locally, set enable_signup = true in supabase/config.toml and restart. Then test a fresh sign-up.
- Supabase RLS errorSupabase: “infinite recursion detected in policy for relation”A policy on the table queries a table with RLS on, and that table’s policy ends up running the first policy again. Move the lookup into a security definer function in a private schema, with search_path set to an empty string, and call it from both policies. Don’t fix it by turning RLS off or by writing a policy that lets everyone read.
- Supabase API errorSupabase: “permission denied for table” (42501)Run the grants query below to see what anon and authenticated may do on the table, then grant only what the app needs, such as select to anon or select, insert, update and delete to authenticated. Keep RLS on with policies, because the grant opens the table to the API. If the error names a sequence, column or schema, see the matching cause below.
- Supabase Auth errorSupabase Auth: over_request_rate_limit (429 Too Many Requests)Check the network tab for repeated auth calls and fix the loop first. If sign-ins go through your own server, every user shares its IP: turn on IP address forwarding and send the user’s IP, or sign in from the browser. Raise the limits in Authentication > Rate Limits only for real traffic.
- Supabase API errorSupabase: “Invalid API key”Copy the publishable key and the URL from the same project’s API settings, set them in your host’s environment variables, and rebuild. If legacy keys were disabled or a key was rotated, move the app to the current publishable key. Send keys on the apikey header.
- Supabase Auth errorSupabase Auth: Email address not authorizedSet up a custom SMTP provider in the Auth settings, with the host, port, user, password and a From address from your email service. After that, confirmation, magic link and reset emails go to any address. For a quick test before then, add the tester to the organization’s team.
- Supabase performance problemWhy is my Supabase app so slow?Open the Performance Advisor and the Query Performance report in the Supabase dashboard. They point at missing indexes and security policies that check every row. Then check that the app fetches only the rows and columns it shows, that the project region is near your users, that serverless code uses the shared pooler, and whether CPU is maxed out before paying for more compute.
- Supabase billingSupabase bill spike: find what you’re paying for, then cut itOpen the organization’s Usage page and the Upcoming Invoice on the billing page, then pick each project from the dropdown to see which one grew. Compute is billed per project by the hour and is not covered by the Spend Cap, so an extra project, a bigger compute size, branches or read replicas add to the bill on their own. For usage lines such as egress or realtime messages, find the query or listener sending too much data and fix that first. Then delete projects you don’t use.
- Supabase database problemSupabase database full: the app reads but won’t saveCheck disk usage on the project’s Infrastructure page. On the Free plan the disk is a fixed 2 GB, so delete data you don’t need or upgrade. On a paid plan the disk grows on its own at 90%, but only four times in a rolling 24 hours, so a fast-growing database can still hit 95%; increase the disk size yourself. To delete data while read-only, Supabase documents a session override that turns writes back on for that session.
Looking for another platform? See the other fixes.
A different Supabase error?
Describe it and get a written quote
Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.