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:
{
"code": "PGRST002",
"details": null,
"hint": null,
"message": "Could not query the database for the schema cache. Retrying."
}
{
"code": "PGRST002",
"details": null,
"hint": null,
"message": "Could not query the database for the schema cache. Retrying."
}
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)
No description
15 Replies
xobzoo
xobzooOP5h ago
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.)
garyaustin
garyaustin5h ago
Check the PostgREST logs in the dashboard to see what it says.
xobzoo
xobzooOP5h ago
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
No description
xobzoo
xobzooOP5h ago
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)
garyaustin
garyaustin5h ago
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.
xobzoo
xobzooOP5h ago
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:
{
"event_message": "Failed to load the schema cache using db-schemas=public,storage,graphql_public,sec,main,core,care and db-extra-search-path=public,extensions. {\"code\":\"3F000\",\"details\":null,\"hint\":null,\"message\":\"schema \\\"sec\\\" does not exist\"}",
"id": "99c46fc5-0063-4b7a-b523-18e123207493",
"metadata": [
{
"_AUDIT_LOGINUID": null,
"_AUDIT_SESSION": null,
"_LINE_BREAK": null,
"host": "db-jxhjktemlmxwxzmhaila",
"metadata": [],
"project": null,
"source_type": null
}
],
"timestamp": 1759472473160529
}
{
"event_message": "Failed to load the schema cache using db-schemas=public,storage,graphql_public,sec,main,core,care and db-extra-search-path=public,extensions. {\"code\":\"3F000\",\"details\":null,\"hint\":null,\"message\":\"schema \\\"sec\\\" does not exist\"}",
"id": "99c46fc5-0063-4b7a-b523-18e123207493",
"metadata": [
{
"_AUDIT_LOGINUID": null,
"_AUDIT_SESSION": null,
"_LINE_BREAK": null,
"host": "db-jxhjktemlmxwxzmhaila",
"metadata": [],
"project": null,
"source_type": null
}
],
"timestamp": 1759472473160529
}
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?)
garyaustin
garyaustin5h ago
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.
xobzoo
xobzooOP5h ago
Oh, sure enough… https://supabase.com/dashboard/project/_/settings/api has this to say about things:
No description
xobzoo
xobzooOP5h ago
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…
garyaustin
garyaustin5h ago
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.
xobzoo
xobzooOP5h ago
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).
garyaustin
garyaustin5h ago
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.
xobzoo
xobzooOP5h ago
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
garyaustin
garyaustin5h ago
I can assure that Free/Pro makes no difference for that setting ever. Out for the night.
xobzoo
xobzooOP5h ago
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. 😄)

Did you find this page helpful?