AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Persistent 504 Errors On Supabase Auth Endpoints Due To Database Connection Pool Exhaustion During Peak Hours

Project zvusdpixljxkxlxrrauj (Pro) experiences 5xx/504 errors on /auth/v1/* during weekday business hours, primarily affecting token refresh and user lookup endpoints. The issue is likely caused by database connection pool exhaustion in the GoTrue auth service under concurrent load, leading to requests exceeding the 60-second timeout.

highConfidence 70%Supabase

Origin Analysis

The GoTrue auth service is configured with an insufficient database connection pool size. During peak business hours, concurrent token refresh and user lookup operations exhaust the pool, causing requests to queue and exceed the 60-second timeout, resulting in 504 Gateway Timeout errors.
1. During peak hours (06:00-15:00 UTC weekdays), send concurrent requests to /auth/v1/token?grant_type=refresh_token and /auth/v1/user endpoints.\n2. Observe that a subset of requests hang and return 504 after 60 seconds.\n3. Check database pool metrics and note that the pool is saturated.

Fixing Code Block

Edge Case Audit

Increasing the pool size may put additional load on the PostgreSQL database, potentially degrading overall performance if the database lacks sufficient resources. Monitor database CPU, memory, and connection counts after applying the change. Consider using PgBouncer for more efficient connection pooling. To rollback, revert to the previous configuration values.

Ecosystem Topology