caelum0x a8e8648a9b feat: composite action that keeps a free Supabase project from pausing
REST root ping + cheap table/rpc query with the anon key, retries with
backoff, job summary, early warnings (stale last success, weekly cron,
GitHub 60-day schedule disable), copy-paste workflow examples and a
curl-only fallback. Self-test workflow runs against a real endpoint.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-12 07:54:48 +03:00

Supabase keep-alive GitHub Action

A reusable GitHub Action that stops a free Supabase project from being paused for inactivity. Once a day it calls the project's REST API and runs one cheap database query with the anon key, retries on transient errors, writes a job summary you can read at a glance, and warns you before the 7-day window closes (last success too old, weekly cron, GitHub about to disable your schedule). Plain bash and curl, no Node, no Python, no dependencies to update.

- uses: caelum0x/supabase-keep-alive-action@v1
  with:
    url: ${{ secrets.SUPABASE_URL }}
    anon-key: ${{ secrets.SUPABASE_ANON_KEY }}
    table: keepalive

If you only want the answers to "why was my project paused" and "how do I get it back", they are first. The action comes after.

Why Supabase pauses free projects

Supabase's pricing page states it plainly: "Free projects are paused after 1 week of inactivity" and the Free plan has a "Limit of 2 active projects" (pricing). The production checklist says the same thing with a little more nuance: "We may pause applications on the Free Plan that exhibit low activity in a 7-day period to save on server resources" (going into production).

What counts as activity, per the official FAQ: "Opening the project in the dashboard or sending real requests from your app both count as activity", and "You get an email about a week before a pause, and another once it happens" (Do Supabase projects pause when they're inactive?). Supabase does not publish the exact threshold, and community reports disagree on whether direct Postgres connections (connection string, pooler) count. Requests through the project's API that touch the database are the documented path, which is what this action makes.

Paid plans are never paused for inactivity: "Upgrade to Pro to guarantee that we won't pause your project for inactivity" (same production checklist).

How to tell if your project is paused

A paused project answers every API request with HTTP 540. From Supabase's status code reference: "The project the request was being made against has been paused. The project cannot process requests until it is un-paused by the owner" (HTTP status codes).

curl -s -o /dev/null -w '%{http_code}\n' \
  -H "apikey: $SUPABASE_ANON_KEY" "https://YOUR-REF.supabase.co/rest/v1/"
# 200 = awake, 540 = paused

In a browser the symptom is usually a bare network error, because the paused gateway answers without CORS headers, so your app reports "Failed to fetch" or "Load failed" instead of 540.

How to restore a paused project

  1. Open the project in the Supabase dashboard and click Restore project. It takes a few minutes. "A paused project keeps all of its data and settings" (FAQ above).

  2. You need a free slot: the Free plan allows 2 active projects. Paused projects do not count towards that limit, so if two others are running, pause one first.

  3. Do not wait too long. "When a project is paused, users have a 1-year window to restore the project on the platform from within Supabase Studio. [...] After the restore window, you can download your project's backup file, and Storage objects from the project dashboard" (upgrading docs). The dashboard shows a countdown on paused projects.

    You may read elsewhere that paused projects are deleted after 90 days. As of 2026-11-12 the docs linked above say one year for one-click restore, with a downloadable backup after that. Check the current docs before relying on either number.

  4. A restored project is paused again if the next 7 days are quiet. Add the workflow below the same day you restore.

How this action prevents it

Every run does, in order:

  1. GET /rest/v1/ with your anon key. Confirms the gateway and PostgREST answer, and catches HTTP 540 (paused) and 401 (wrong key) with a clear error.
  2. A real database query, one of:
    • GET /rest/v1/<table>?select=*&limit=1 when you set table:. The table can have Row Level Security enabled with no policy for anon; the query still runs, it just returns []. Nothing is exposed.
    • POST /rest/v1/rpc/<function> when you set rpc:.
  3. Retries with exponential backoff (2s, 4s, 8s) on network errors, 429 and 5xx. 4xx and 540 are not retried; they are reported.
  4. Early warnings, printed as workflow annotations and in the job summary:
    • the previous successful run of this workflow is older than warn-after-days (default 5);
    • the cron in your workflow is weekly or monthly, which leaves no margin inside 7 days;
    • the repository has had no push for 45+ days. "In a public repository, scheduled workflows are automatically disabled when no repository activity has occurred in 60 days" (GitHub docs). This is the most common reason hand-rolled keep-alive workflows stop silently.
  5. A job summary table (check, request, HTTP status, latency, attempts) and step outputs.

Set it up in two minutes

  1. Add two repository secrets under Settings, Secrets and variables, Actions: SUPABASE_URL (for example https://abcdefgh.supabase.co) and SUPABASE_ANON_KEY (Project Settings, API, anon public key).
  2. Create .github/workflows/keep-alive.yml:
name: Keep Supabase alive

on:
  schedule:
    - cron: "17 6 * * *"   # daily; avoid :00, GitHub's busiest minute
  workflow_dispatch:

permissions:
  contents: read
  actions: read            # lets the action read its own previous runs

jobs:
  ping:
    runs-on: ubuntu-latest
    steps:
      - uses: caelum0x/supabase-keep-alive-action@v1
        with:
          url: ${{ secrets.SUPABASE_URL }}
          anon-key: ${{ secrets.SUPABASE_ANON_KEY }}
          table: keepalive
  1. Run it once from the Actions tab (Run workflow) and read the job summary.

Copy-paste versions: examples/keep-alive.yml, examples/multi-project.yml (several projects via a matrix), examples/curl-only.yml (no action at all).

Pick a cheap query

Any existing small table works for table:. If you would rather not point it at real data, run this once in the SQL editor:

create table if not exists keepalive (
  id bigint generated always as identity primary key,
  created_at timestamptz not null default now()
);
alter table keepalive enable row level security;   -- no policy: anon reads return [] but the query runs
grant select on keepalive to anon;

Or a function, which touches no table at all:

create or replace function keepalive_ping() returns text
language sql stable as $$ select 'ok ' || now()::text $$;
grant execute on function keepalive_ping() to anon;

and set rpc: keepalive_ping instead of table:.

If you set neither, the action still pings the REST root and succeeds, but prints a warning, because the root endpoint alone may not count as database activity.

Inputs

Input Required Default What it does
url yes Project origin, https://<ref>.supabase.co. Use a secret or variable.
anon-key yes Anon public key. Masked in logs.
table no Table to read with select=<select>&limit=1.
select no * Columns for the table read.
rpc no Function to call with POST /rest/v1/rpc/<rpc>.
rpc-body no {} JSON body for the rpc call.
retries no 3 Retries per request after the first attempt.
timeout no 20 Per-request timeout, seconds.
warn-after-days no 5 Warn when the last successful run is older than this.
fail-on-paused no true Fail the step on HTTP 540. false only warns.
github-token no ${{ github.token }} Reads previous runs, the cron and the last push date for the warnings. Set to "" to skip.

Outputs

status (ok, paused, failed), rest-status, query-status, paused, last-success-days.

- id: ping
  uses: caelum0x/supabase-keep-alive-action@v1
  with: { url: "${{ secrets.SUPABASE_URL }}", anon-key: "${{ secrets.SUPABASE_ANON_KEY }}", table: keepalive }
- if: steps.ping.outputs.paused == 'true'
  run: echo "restore the project in the dashboard"

Without the action: one curl

curl -s -o /dev/null -w '%{http_code}\n' --max-time 20 \
  -H "apikey: $SUPABASE_ANON_KEY" -H "Authorization: Bearer $SUPABASE_ANON_KEY" \
  "$SUPABASE_URL/rest/v1/keepalive?select=*&limit=1"

Put that in a daily cron anywhere (a server, a Cloudflare Worker, another CI). You lose the retries, the summary and the early warnings, but it is the smallest thing that works. examples/curl-only.yml is the GitHub Actions version.

Limits, honestly

  • It works around the Free plan's intent. Supabase pauses idle projects "to save on server resources". A keep-alive makes a project look busier than it is. Supabase has not, to our knowledge, forbidden this, but their only documented guarantee is a paid plan.
  • No guarantee. Supabase does not publish a precise activity threshold and may change how it measures it. One request a day through the REST API is the common, working practice; it is not a contract. Several people have reported pauses despite steady pings.
  • GitHub schedules are best effort. Cron runs "can be delayed during periods of high loads", only run on the default branch, and are disabled after 60 days without a push to a public repo. A weekly cron plus one delayed run can miss the window, which is why the action warns on weekly schedules and old last-success dates. Run it daily.
  • It cannot unpause. Once a project is paused, only the dashboard can restore it; the action reports 540 and fails so you notice.
  • pg_cron inside the database cannot do this job. When the project pauses, Postgres is not running, so nothing inside it can wake it.
  • The anon key is public by design (it ships in your frontend), but it still belongs in a secret, not in the workflow file, so it is masked and not indexed.

If you'd rather not babysit it

The keep-alive exists because a free project that nobody touches for a week is turned off and has to be turned back on by hand. Scribase is a backend built around the opposite behaviour: each project is Postgres + Auth + Storage + Realtime, idle projects scale to zero on their own and wake on the next request, so there is nothing to keep alive and nothing to restore. Existing supabase-js code works by swapping the URL and keys. It is free for 14 days with no card, then from $5 per project. The test workflow in this repository runs against a Scribase project through the same /rest/v1/ and apikey calls shown above, which is also why the action works unchanged against either.

Supabase's free plan is generous and this action is for people who want to stay on it. The paragraph above is for the ones who would rather pay a little and stop thinking about it.

Compared with other approaches

  • Vercel cron + Next.js route (for example travisvn/supabase-pause-prevention): works well if you already deploy to Vercel. You need a deployed app and the Hobby plan limits cron jobs.
  • A Python or Node script run by Actions (for example travisvn/supabase-inactive-fix): inserts and deletes rows in a table. Flexible, but you maintain a runtime and dependencies, and it writes to your database.
  • This action: a uses: line, read-only queries, no runtime, retries, a summary and the pre-pause warnings. If you want write activity, point rpc: at a function that does an insert.

Self-test

.github/workflows/self-test.yml runs the action in this repository against a real PostgREST-compatible project on every push and daily, with a table read, an rpc call and a no-query run that must warn but pass. The URL and key are repository secrets; nothing in the repository contains a key.

License

MIT. Not affiliated with Supabase.

Description
Stop a free Supabase project from pausing after 7 idle days: one copy-paste GitHub Actions workflow (bash + curl), a cron script and a CLI. Detects HTTP 540 (paused) and warns before the window closes.
https://scribase.com/?utm_source=rithub&utm_medium=repo&utm_campaign=supabase-keep-alive Readme MIT 120 KiB
1.1.0 Latest
2026-11-17 11:21:23 +00:00
Languages
JavaScript 52.2%
Shell 47.8%