BrandPilot — Supabase Connection Failed

Trigger: https://p24-brandpilot.zintegrowana.online/api/health returns supabase.ok: false OR app returns 503 with “Supabase connection failed” in logs.

Supabase project: dedicated free-tier project (account: admin@p24-brandpilot.zintegrowana.online)


1. Confirm

curl -s https://p24-brandpilot.zintegrowana.online/api/health | python -m json.tool
# Look for: "supabase": { "ok": false }

2. Diagnose

2a. Check Supabase platform status

curl -s https://status.supabase.com/api/v2/status.json | python -m json.tool

Or visit: https://status.supabase.com

If there is an active incident → wait for Supabase to resolve. No action needed on our side.

2b. Check if the Supabase project is paused

Free-tier Supabase projects auto-pause after 7 days of inactivity.

Sign in to https://supabase.com/dashboard with admin@p24-brandpilot.zintegrowana.online credentials. (Credentials in p24-infra/secrets/brandpilot.env.sops.)

If the project shows “Paused” banner → human action required (see Fix A).

2c. Verify environment variables in Vercel

Check that NEXT_PUBLIC_SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are set and correct in Vercel:

vercel env ls --environment production

Or via Vercel dashboard → Settings → Environment Variables.

Compare against values in p24-infra/secrets/brandpilot.env.sops.

If they differ → re-sync by running the secrets-sync.yml GitHub Actions workflow:

gh workflow run secrets-sync.yml -R p24-infra/brandpilot

2d. Test Supabase connectivity directly

# Replace with actual SUPABASE_URL value from SOPS (do NOT paste the key here):
curl -s "https://<project-ref>.supabase.co/rest/v1/" \
  -H "apikey: <NEXT_PUBLIC_SUPABASE_ANON_KEY>"
# Expect 200; a 503 or "project paused" body confirms the project is paused

3. Fix

Fix A: Unpause the project (human action required)

There is no API to unpause a Supabase free-tier project. A human must:

  1. Go to https://supabase.com/dashboard
  2. Log in with admin@p24-brandpilot.zintegrowana.online
  3. Select the BrandPilot project
  4. Click “Restore project” in the paused banner
  5. Wait 1-2 minutes for the project to restart

Apply human-action label to any related infra-alert issue.

Fix B: Set up a keepalive to prevent future pauses

To avoid repeated pauses, add a cron job or n8n scheduled workflow that pings the Supabase REST API once per day:

# Daily keepalive ping (add to n8n or a GitHub Actions schedule):
curl -s "https://<project-ref>.supabase.co/rest/v1/profiles?select=id&limit=1" \
  -H "apikey: $NEXT_PUBLIC_SUPABASE_ANON_KEY" \
  -H "Authorization: Bearer $NEXT_PUBLIC_SUPABASE_ANON_KEY"

Long-term: If the project pauses frequently, consider upgrading Supabase to the Pro plan.

Fix C: Rotate credentials if key is invalid

If the anon key or service role key has been rotated in Supabase but Vercel still has the old value:

  1. Get new keys from Supabase dashboard → Settings → API
  2. Update p24-infra/secrets/brandpilot.env.sops (SOPS+age)
  3. Push → secrets-sync.yml auto-syncs to Vercel
  4. Trigger a Vercel redeployment to pick up new env vars

4. Escalate to human when

  • Project needs to be unpaused (always requires human action — no API available)
  • Supabase platform is experiencing an incident → monitor https://status.supabase.com
  • Credential rotation needed (requires Supabase dashboard + SOPS update)

5. Verify fix

curl -s https://p24-brandpilot.zintegrowana.online/api/health | python -m json.tool
# Expect: { "status": "ok", "supabase": { "ok": true } }