Guide
PGRST106: "The schema must be one of the following"
How this guide was made: Written with AI assistance and checked against the sources linked on this page.
Updated
Short answer: PGRST106 means your app asked the Supabase API for a database schema that is not on its list of exposed schemas. Add the schema under Exposed schemas in your project's API settings, grant the API roles access to it, and check that the schema name in your code is spelled exactly right. If a role-level override exists, reset it.
What it means
Supabase's REST API (PostgREST) only serves the schemas on its exposed list. Out of the box that list holds public and a few Supabase system schemas, not your own. When your code asks for any other schema, through createClient(..., { db: { schema: 'x' } }), supabase.schema('x'), or an Accept-Profile / Content-Profile header, and that schema is not on the list, the request fails with HTTP 406 and a body like this:
{"code":"PGRST106","message":"The schema must be one of the following: public"}
The names after "one of the following" are the schemas the API exposes right now. Compare them with the schema your code asked for. That comparison tells you which fix you need.
Causes
| Cause | How to tell | Fix |
|---|---|---|
| The schema was never added to Exposed schemas | Your schema is missing from the list in the error, and Exposed schemas in API settings does not show it | Step 1, then Step 2 |
| The schema name in the code does not match the database | The list in the error contains a similar name (App vs app, api vs api_v1), or the schema does not exist in the Table Editor | Step 3 |
An authenticator role override ignores the dashboard setting | You added the schema in the dashboard but the error still lists the old set; the Step 4 query shows pgrst.db_schemas in rolconfig | Step 4 |
| The app talks to a different Supabase project | The error's list does not match what you see in your dashboard; the project URL in your env vars points somewhere else | Step 5 |
Fix steps
1. Expose the schema. Open your project in the Supabase dashboard, go to the API settings page (https://supabase.com/dashboard/project/_/settings/api), find Exposed schemas, add your schema, and save. Keep public in the list if your app still uses it.
If the schema does not exist yet, create it first in the SQL editor:
CREATE SCHEMA myschema;
2. Grant the API roles access. Exposing a schema does not give anyone access to it. Run this in the SQL editor, with myschema replaced by your schema name:
GRANT USAGE ON SCHEMA myschema TO anon, authenticated, service_role;
GRANT ALL ON ALL TABLES IN SCHEMA myschema TO anon, authenticated, service_role;
GRANT ALL ON ALL ROUTINES IN SCHEMA myschema TO anon, authenticated, service_role;
GRANT ALL ON ALL SEQUENCES IN SCHEMA myschema TO anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA myschema GRANT ALL ON TABLES TO anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA myschema GRANT ALL ON ROUTINES TO anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA myschema GRANT ALL ON SEQUENCES TO anon, authenticated, service_role;
These grants open the tables to the API roles. Row Level Security policies still decide which rows each user can read or change, so turn RLS on for every table that holds user data.
3. Use the exact schema name in the code. Search your code for schema: and .schema( and make the name match the database exactly. Either set it once for the whole client:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, {
db: { schema: 'myschema' },
})
const { data, error } = await supabase.from('todos').select('*')
or switch per query and leave the default on public:
const { data, error } = await supabase.schema('myschema').from('todos').select('*')
If you use generated TypeScript types, createClient<Database>(...) only accepts public for db.schema. Pass the schema as a second generic, createClient<Database, 'myschema'>(...), and make sure myschema is in your generated Database type.
If you call the REST API directly, send Accept-Profile: myschema on GET and HEAD, and Content-Profile: myschema on POST, PATCH, PUT and DELETE.
4. Remove a role-level override. A pgrst.db_schemas setting on the authenticator role takes the place of the dashboard list. Check for one:
SELECT rolname, rolconfig
FROM pg_roles
WHERE rolname IN ('authenticated', 'authenticator', 'anon', 'postgres', 'service_role');
If the authenticator row shows pgrst.db_schemas=..., reset it so the dashboard setting applies again:
ALTER ROLE authenticator RESET pgrst.db_schemas;
Or, if you want to keep the override, list every schema you need in it:
ALTER ROLE authenticator SET pgrst.db_schemas = 'public, myschema';
Then ask the API to reload its config:
NOTIFY pgrst, 'reload config';
5. Confirm the project. Check that the Supabase URL and key in your app's environment variables (both locally and on your host) belong to the project you just changed. A preview or production build pointed at an older project will keep returning the old list.
How to verify it's fixed
- Run the query that failed in your app. It should return data or an empty array with no error.
- Or test the API directly (replace the project ref, key, table and schema):
curl "https://YOUR_PROJECT_REF.supabase.co/rest/v1/todos?select=*&limit=1" \
-H "apikey: YOUR_PUBLISHABLE_KEY" \
-H "Accept-Profile: myschema"
A JSON array means the schema is exposed. A body with PGRST106 means it is still missing from the list; read the names in the message and go back to Step 1 or Step 4. 3. If you now see a permission error (42501) instead, the schema is exposed but the grants in Step 2 or your RLS policies are missing.
FAQ
Why is my schema still missing from the list after I added it in the dashboard?
Either the save did not go through, the app points at another project, or the authenticator role has a pgrst.db_schemas override that replaces the dashboard list. Run the Step 4 query to check for the override.
Do I need a custom schema at all?
No. If you only need a few tables, keeping them in public avoids this error entirely. Remove the db.schema option or .schema() call and the client uses public. Custom schemas are useful when you want to keep some tables apart from the ones your API serves.
Is it safe to expose a schema?
Exposing makes the schema reachable through the API with your public key. What anyone can actually read or write is set by the grants and your Row Level Security policies. Turn RLS on and add policies before you expose tables that hold user data.
Still stuck? Run a free check on VibeFix: the agent finds the cause in your live app, and for $79 it fixes it in your code and re-checks the app.
Can VibeFix fix it for me?
Yes, for apps built in Lovable or any app whose code is on GitHub. The free check confirms the problem on your live app first. If you want it fixed, our AI agent finds the cause, fixes it in your code for $79 and tests your live app again. See pricing.
Sources
- <https://docs.postgrest.org/en/stable/references/errors.html>
- <https://supabase.com/docs/guides/api/rest/postgrest-error-codes>
- <https://docs.postgrest.org/en/stable/references/api/schemas.html>
- <https://supabase.com/docs/guides/api/using-custom-schemas>
- <https://supabase.com/docs/guides/troubleshooting/pgrst106-the-schema-must-be-one-of-the-following-error-when-querying-an-exposed-schema>
- <https://docs.postgrest.org/en/stable/references/configuration.html>
- <https://supabase.com/docs/guides/local-development/cli/config>
Last checked: 16 November 2026.
VibeFix is independent. Supabase and Stripe are trademarks of their owners.
Want it fixed?
Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.
It starts with a free check that confirms the problem on your live app, no account needed.
More guides · Shopify store accessibility · About · Your privacy choices