Hi! Hoping someone can help me sanity-check what we're seeing.
What's happening Our Next.js app on Vercel is getting random 504s from Supabase REST. The response says:
proxy_status: PostgREST; error=PGRST003
origin_time: ~60–125 seconds
status: 504
Even a tiny query from middleware fails:
GET /rest/v1/users?select=username&id=eq.<uuid>
It hangs for ~60s, then 504. At the same time, /auth/v1/user and /auth/v1/token keep returning 200. Only /rest/v1/* times out.
What I've already checked
SELECT username FROM users WHERE id = '<uuid>' → Index Scan, ~2 msSELECT sum(views) FROM submissions → Index Only Scan, The user is experiencing 504 errors with the Supabase REST API when their Next.js app on Vercel is under load. The issue seems related to connection pool limitations on the Free tier. They are seeking clarification on the PGRST003 error and advice on handling Vercel builds that pre-render many pages.
pg_stat_activity shows no stuck transactions, no idle in transaction.postgrest connections; on Free I see only 1.My guess
The PostgREST connection pool on Free tier is small. When we get a burst of traffic (Vercel build doing static generation for a lot of pages, or normal SSR/middleware load), requests queue up waiting for a DB connection and time out at ~60s with PGRST003. Postgres itself is fine — it never even sees these requests.
Environment
@supabase/ssr@0.8.0, @supabase/supabase-js@2.87.1createServerClient from @supabase/ssr in middleware + SSRQuestions
Is PGRST003 always a PostgREST pool timeout, or can it also come from the upstream gateway / Supavisor?
What is the actual PostgREST pool size on Free tier, and does it grow on paid plans / bigger compute?
Any best-practice advice for Vercel builds that pre-render many pages against Supabase, beyond "upgrade tier"?