PostgREST Schema Cache issue – `PGRST002`
I've been having problems with the REST API of one project.
I know the DB is still happy, because actual SQL queries work just fine (both in the browser and DBeaver).
The REST part is failing, though. At least mostly.
-
https://{{server}}/auth/v1/…
works fine (sign in, sign out, current user info …/auth/v1/user
)
- https://{{server}}/rest/v1/…
returns 503 Service Unavailable
The full error response:
The PostgREST documentation says that error means
Could not connect with the database when building the Schema Cache due to the PostgreSQL service not running.But SQL queries still work fine…. (probably “the PostgreSQL service” is not what I think it sounds like)

15 Replies
Trying to fix it through the website
I tried to debug/fix it through the website: https://supabase.com/dashboard/project/_/api
Unfortunately, that page has an error, too:
(That stupid Discord interface tricked me. The message was supposed to go before the picture, which attached to the wrong thing.)
Check the PostgREST logs in the dashboard to see what it says.
What else I've tried
- I confirmed that it's just this project/organization (my own personal project has no problems)
- I tried to debug it through the project dashboard, but could not (as shown above)
- I migrated to use the new API keys (behavior is identical to the legacy JWT keys)
- I restarted the Supabase project
- checked the Supabase status page, but nothing seems to apply to my situation (we're in
us-east-1
)
- verified that the Data API is turned on (see below)
- waited a day, to see if it would resolve itself
My questions
- Is this something that happens to others very often?
- Did it break because of something we did? (such as some settings that got tweaked)
- Is there something I can do to fix myself? (like restarting the project… except that didn't work)
And if I have to make a support request, I might need some guidance on what values to pick. (the options available on the page I see are … not quite accurate)
I've seen this if a schema is deleted in the database but still is in the API settings for schemas PostgrREST can access. If so the PostgREST log should have that detail.
Okay; I didn't think any schema were deleted, but I'm willing to try new things.
How do I verify or fix that problem?
I'm looking at the logs in https://supabase.com/dashboard/project/_/logs/postgrest-logs and seeing …
Well, here's one that might actually be [related to] the issue:
That would seem to indicate that the
sec
schema was deleted, but something is expecting it to be there…
So how do I force it to properly refresh? (or do I just re-create it so it can't complain about that?)I would delete sec from the API settings page for either search path or schemas available to API. It got added to those most likely and when deleted did not get deleted from the settings.
It would get added there by you or an AI most likely.
Oh, sure enough… https://supabase.com/dashboard/project/_/settings/api has this to say about things:

If only I'd just looked further down the page when I confirmed it was enabled… and if I'd known that was a potential problem…
It is an odd high level error on schema cache that only knowing a common cause is that type of error in the PostgREST log.
But I thought that only
public
was available through REST while on the free tier. (as I remember it, our DBE changed his model to put everything in the same schema for the purposes of our evaluation (with the plan that we'd move things around later if Supabase became our permanent solution).Not heard of that. The option to include any schema has always been there.
Some take away public and only have their own custom schemas for super security.
But if a schema is there it has to exist.
Hmm.
Well, at some point I'll talk to our DBE about this and see what I'm mis-remembering, or what we misunderstood, or whatever.
(it could be that we were misinformed by someone else's testimony of how it works…)
He may be elated to find out that we can do things differently, even while free. Or maybe I'm hallucinating the whole conversation. /shrug
I can assure that Free/Pro makes no difference for that setting ever.
Out for the night.
Thanks for your help!
Hopefully within a few minutes all the settings will cascade down to the front end and I can confirm that this is solved.
Yep! Everything's working now. (and the settings move quicker after clicking the "Save" button… Who'da thunk it. 😄)