Supabase Sign-In Was Down and the Database Looked Fine. The 401 Was Lying.
In short
GET /rest/v1/ without an apikey returns 401 from Supabase's API gateway whether or not the database is reachable, and during my outage it answered in about 0.15s while auth, PostgREST and storage were all down. The honest probes are a real table select with the anon key, /storage/v1/version as a control, psql with a wrong password, and the Management API /health endpoint, which said db UNHEALTHY while the project status said ACTIVE_HEALTHY. Restart through the Management API, re-check /health and restart again if needed, then get off Nano compute.

On this page
- What did the outage look like from the outside?
- Why does GET /rest/v1/ return 401 when the database is down?
- Which probes tell you whether a Supabase database is reachable?
- Why did Supabase say ACTIVE_HEALTHY while the database was down?
- How do you restart a Supabase project from the API?
- How did my own app make the outage worse?
- What's the runbook when Supabase sign-in is down?
- What would I do differently next time?
Short answer: GET /rest/v1/ without an apikey returns 401 from Supabase's API gateway whether or not your database is reachable, so it proves nothing about the database. During a sign-in outage on a production legal marketplace I maintain, that request answered 401 in about 0.15 seconds for the entire outage while auth, PostgREST and storage were dead, and I read it as "the database is fine". The probes that told the truth were a real table select with the anon key, the storage version endpoint as a control, psql with a deliberately wrong password, and the Management API's /health endpoint, which reported the database as unhealthy while the project status still said ACTIVE_HEALTHY. A project restart through the Management API fixed it on the second attempt, and moving off Nano compute took sign-in from 10 to 35 seconds down to under a second.
What did the outage look like from the outside?
On 4 September 2026, sign-in stopped working on that app, and it stayed broken for hours. It runs on Next.js, with Supabase behind auth and the database.
From a user's seat: sign-in didn't work, and the whole signed-in site hung, not only the sign-in page. Some requests came back as 504s.
Underneath, Supabase's data plane was down. Auth (GoTrue), PostgREST and storage were all failing. Postgres itself was healthy. That split is what made it slow to diagnose, because the first check I reached for was looking at a layer that never touches the database.
Why does GET /rest/v1/ return 401 when the database is down?
Because the 401 never gets as far as the database. Supabase's REST API is "provisioned behind an API gateway with key-auth enabled", per the Supabase API docs ↗, and the architecture page ↗ lists the API gateway as its own component. A request with no apikey header is rejected at that gateway. PostgREST never sees it. Postgres never sees it.
curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" \
"https://<project>.supabase.co/rest/v1/"
# 401, about 0.15s. Answered by the gateway, not the database.During the outage that came back 401 in about 0.15 seconds, start to finish. Fast and consistent. It looked exactly like a healthy service refusing an anonymous caller. I took it to mean PostgREST and the database were fine, and concluded that auth alone was broken.
That conclusion was confident and wrong. Every DB-backed service was down. The 401 cost more time than anything else in the incident, because it pointed the investigation at auth. Here is what I ruled out along the way, so nobody repeats it:
- Rate limiting. None of the 504s carried
x-ratelimit-*orretry-afterheaders. - A paused project. Storage's version endpoint answered 200, so the project was running.
- The signup trigger on new users. It fires only on the signup
INSERT, so it cannot affect/auth/v1/health. - Auth hooks. None were configured.
The general rule: a fast error from a gateway is a statement about the gateway.
Which probes tell you whether a Supabase database is reachable?
Two HTTP probes and one psql command. Run the HTTP pair side by side, because the useful signal is the difference between them.
export SUPABASE_URL="https://<project>.supabase.co"
export ANON_KEY="<anon key>"
# 1. Liveness: needs a real database connection, so it hangs when the DB is unreachable.
curl -s -o /dev/null --max-time 10 -w "rest %{http_code} %{time_total}s\n" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $ANON_KEY" \
"$SUPABASE_URL/rest/v1/<table>?select=id&limit=1"
# 2. Control: no database involved. If this answers, the project is running and not paused.
curl -s -o /dev/null --max-time 10 -w "storage %{http_code} %{time_total}s\n" \
-H "apikey: $ANON_KEY" "$SUPABASE_URL/storage/v1/version"The --max-time matters. Without it, probe 1 just hangs and you sit there wondering. With it, curl gives up after ten seconds and you get a failed request you can read. If the liveness probe times out while the control answers 200, the project is up and not paused, so the hang is saturation.
Then the one that settles whether Postgres itself is alive:
psql "postgresql://postgres:deliberately-wrong@db.<project-ref>.supabase.co:5432/postgres" \
-c "select 1"FATAL: password authentication failedmeans Postgres is up and processing connections. It got far enough to check your password.too many clientsmeans connections are exhausted.
Two cautions. First, the direct database host is IPv6. The connection docs ↗ say direct connections are on IPv6 unless the project has the IPv4 add-on, so run this from a machine that has IPv6. /dev/tcp port checks were unreliable over IPv6. psql is the authoritative one. Second, run it once, not in a loop. Supabase temporarily bans IPs ↗ whose traffic looks abusive, and its example is multiple failed auth attempts.
Why did Supabase say ACTIVE_HEALTHY while the database was down?
Because the project status and the service health are two different endpoints, and only one of them was honest.
You need a personal access token for the Management API ↗. The personal access tokens page ↗ lists which permission each endpoint needs. Then:
export SUPABASE_ACCESS_TOKEN="<personal access token>"
export PROJECT_REF="<project ref>"
export API="https://api.supabase.com/v1/projects/$PROJECT_REF"
# Project status. Still said ACTIVE_HEALTHY during the outage.
curl -s -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" "$API" | jq -r .status
# Per-service health. This is the one that told the truth.
curl -s -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
"$API/health?services=db&services=auth&services=rest&services=storage" \
| jq '.[] | {name, status, error}'The get project endpoint ↗ returned ACTIVE_HEALTHY. The service health endpoint ↗ reported db as UNHEALTHY, with "Failed to connect to database".
The status field can express trouble. Its enum in the API spec includes ACTIVE_UNHEALTHY. But it also includes COMING_UP, PAUSING, RESTARTING, RESIZING and RESTORING, and my reading is that it describes what the platform is doing to the project, not whether the services inside it can reach Postgres. Whatever the reason, the rule is simple: trust /health, not status.
How do you restart a Supabase project from the API?
With a POST to the restart endpoint ↗, using the same token:
curl -s -X POST -w "%{http_code}\n" \
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" "$API/restart"
# Then poll health until db, auth and rest all report ACTIVE_HEALTHY.
for i in $(seq 1 30); do
curl -s -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
"$API/health?services=db&services=auth&services=rest" \
| jq -r '.[] | "\(.name) \(.status)"' | paste -sd' '
sleep 10
doneThe first restart did not take. The second one did. That is why the polling loop is in the snippet: the restart call accepting your request tells you nothing about whether the services came back. Re-run /health and the liveness probe, and restart again if db is still unhealthy.
A restart brings the services back. It doesn't change why they fell over. The project was on Nano compute, which is what let it saturate. The compute docs ↗ put Nano at a shared CPU, up to 0.5 GB of memory and a baseline of 250 IOPS. The next tier up, Micro, has 1 GB and 500 baseline IOPS. Both list the same 60 max database connections and 200 pooler clients, so the upgrade isn't buying a bigger connection cap.
After moving one tier up, sign-in went from 10 to 35 seconds plus timeouts to 0.28 to 0.83 seconds.
Two lines from those docs to know in advance. Compute sizes are not upgraded automatically, because changing size involves downtime, so plan it. And in paid organizations, Nano is billed at the same price as Micro, so a paid project still on Nano is paying for headroom it isn't getting.
How did my own app make the outage worse?
Twice, and both only show up when a dependency is slow rather than down.
The auth check in the request path had no timeout. The app checks the session in the Next.js proxy (Next.js 16 renamed middleware to proxy ↗) by calling supabase.auth.getUser(), which makes a network request to the Auth server ↗. With no timeout, every authenticated request sat about 35 seconds holding a socket. That is why the whole signed-in site hung, not just sign-in. And on failure it redirected to the login page, bouncing people to a page that could not authenticate them either.
The fix was a 3 second timeout on the fetch itself, and a 503 with Retry-After instead of a login bounce. Racing getUser() against a timer is not the same thing: it stops you waiting, but it does not cancel the request or free the socket. AbortSignal.timeout() ↗ on the fetch does. Roughly:
// Illustrative, not the production file.
const AUTH_TIMEOUT_MS = 3_000;
const supabase = createServerClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
cookies: cookieAdapter(request, response),
global: {
// Cancels the request itself, so the socket is released.
fetch: (input, init) =>
fetch(input, { ...init, signal: AbortSignal.timeout(AUTH_TIMEOUT_MS) }),
},
});
let result;
try {
result = await supabase.auth.getUser();
} catch {
return authUnavailable();
}
const status = result.error?.status;
if (result.error && !(status && status >= 400 && status < 500)) {
return authUnavailable(); // timeout, 5xx, network: not a reason to sign anyone out
}
// Only a real 4xx means a bad session: clear cookies and send to login here.
function authUnavailable() {
return new NextResponse("Sign-in is temporarily unavailable.", {
status: 503,
headers: { "Retry-After": "30" }, // seconds; tune to your recovery time
});
}The global.fetch option ↗ is how you hand the client your own fetch. One thing had been done right already: cookie clearing was gated to 4xx responses, so nobody was signed out by the outage.
The monitor piled onto the thing it was monitoring. A cron fires the health checks every 5 minutes and bounds its curl at 90 seconds. But that bound only gives up on the response. The run itself keeps executing. With checks stuck on a dead database, every tick started another full suite on top of the last, including a service-role auth.admin call, against an auth service that was already failing.
The fix is an in-process lock, which works because the app runs as a single pm2 instance, and a run that gets skipped says so instead of pretending it passed:
let running = false;
export async function runMonitor() {
if (running) return { status: "skipped", reason: "previous run still in progress" };
running = true;
try {
return await runAllChecks();
} finally {
running = false;
}
}What's the runbook when Supabase sign-in is down?
The order I'd run it in. Steps 1 to 4 are the quick diagnosis, about ten seconds of work.
1. Control: GET /storage/v1/version (apikey)
no answer -> project down or paused, check that first
2. Liveness: GET /rest/v1/<table>?select=id&limit=1 (anon key, --max-time 10)
fast 200 -> database path is fine, look at auth itself
hang, control OK -> saturation, not a pause
3. Health: GET api.supabase.com/v1/projects/<ref>/health
?services=db&services=auth&services=rest&services=storage
believe this over the project status field
4. Postgres: psql with a deliberately wrong password, once
"password authentication failed" -> Postgres is up
"too many clients" -> connections exhausted
5. Restart: POST api.supabase.com/v1/projects/<ref>/restart
poll /health; if db is still UNHEALTHY, restart again
6. After: if the project is on Nano, schedule the compute upgrade
Never: GET /rest/v1/ with no apikey as a health check. It answers 401 either way.What would I do differently next time?
Ask one question of every health check before trusting it: could this pass with the database unplugged? GET /rest/v1/ without a key could, and did, for hours. A select on a real table could not.
The rule I follow now has three parts. A health probe has to exercise the dependency it claims to check, with a control next to it that doesn't, so the difference tells you which layer is broken. Every network call in the request path gets a timeout that cancels the request, not one that only stops waiting. And when the provider gives you a lifecycle status and a per-service health check, read the health check.
If you run a Supabase app in production and aren't sure your monitoring would catch this, that is the sort of thing I set up under SaaS security and monitoring ↗. Or get in touch ↗.
FAQ
Why does Supabase return 401 on /rest/v1/ when my database is down?
Because that 401 comes from Supabase's API gateway, which rejects any request without an apikey before it reaches PostgREST or Postgres. In my outage it answered in about 0.15 seconds the whole time the database services were unreachable. Use a select on a real table with the anon key instead, because that needs a database connection and hangs when there isn't one.
How do I check if my Supabase database is actually up?
Run a select on a real table with the anon key and a timeout, next to GET /storage/v1/version as a control that needs no database. If the control answers and the select hangs, the project is running but saturated, not paused. psql with a deliberately wrong password settles the rest: "password authentication failed" means Postgres is up, "too many clients" means connections are exhausted.
Can I trust ACTIVE_HEALTHY from the Supabase Management API?
Not on its own. During my outage the project status still said ACTIVE_HEALTHY while the /health endpoint reported the db service as UNHEALTHY with "Failed to connect to database". Query /v1/projects/{ref}/health with services=db, auth, rest and storage, and believe that over the status field.
How do I restart a Supabase project without the dashboard?
Send POST https://api.supabase.com/v1/projects/{ref}/restart with a personal access token as a Bearer token in the Authorization header. Then poll the /health endpoint until db, auth and rest report ACTIVE_HEALTHY, because an accepted restart call does not mean the services came back. My first restart did not take and the second one did.
Should I move my Supabase project off Nano compute?
For anything in production, yes. Nano has a shared CPU, up to 0.5 GB of memory and 250 baseline IOPS, and it is what let my project saturate; one tier up, sign-in went from 10 to 35 seconds plus timeouts to 0.28 to 0.83 seconds. Plan it, because changing compute size involves downtime, and in paid organizations Nano is billed at the Micro price anyway.
Working on something like this?
I build web apps, AI features, and mobile products for clients. If this article matches a problem you have, tell me about it.
Start a conversationMalik Hamza Shabbir · Full-Stack & AI Engineer
I build full-stack and AI products solo: a reputation SaaS in production, RAG pipelines, and React Native apps. I write from what I ship, not from documentation summaries.
Run it on yours
Every number above came from code you can read.
The harness is open and the per-probe log ships with it. If you build one of these systems, or you are choosing between them with real money, the same method is available to you.
Send me an endpoint and I will write an adapter, run it on the same workload under the same rules, and publish the result. It goes in the table whether it wins or not.
Sponsored inclusion is disclosed in the article and the result publishes either way. Paying moves you up the queue, never up the table.
Related articles
My Production Env Changes Did Nothing. A Forgotten .env.local Was Winning.
A stale .env.local sat next to .env.production on a self-managed Next.js server, so my env edits did nothing. Weeks later, a committed copy pointed sign-in at a deleted Supabase project for about 19 hours. These are the checks and deploy rules I use now.
Adding Semantic Search to an Existing SaaS in a Weekend: pgvector Before You Reach for Pinecone
If your SaaS already runs on Postgres, you can add real semantic search in a weekend with pgvector and one Next.js route, no second database. Here is the embed-on-write migration, the HNSW query, a semantic cache, and the vector count where Pinecone or Milvus actually starts to make sense.
Building Next.js Apps for AI Agents: AGENTS.md, @vercel/next-browser, and Agent DevTools in 16.2
Next.js 16.2 makes AI agents first-class users: create-next-app writes a version-matched AGENTS.md (100% vs 79% eval pass rate), @vercel/next-browser hands an LLM screenshots, network, and console in one call, and experimental Agent DevTools exposes framework state. Here is how I set it all up.