How Supabase Cron works
Supabase Cron is the pg_cron extension. A background worker inside Postgres (the
pg_cron scheduler) reads cron.job, starts each job at its time as a separate database
session, and writes the result to cron.job_run_details. A job is just SQL: either a statement, a
function call, or net.http_post() to call an Edge Function. Work through these checks in order.
1. Is the job there, and active?
select jobid, jobname, schedule, command, active
from cron.job
order by jobid;If active is false, switch it back on with select cron.alter_job(<jobid>, active := true);. Check the schedule string: pg_cron uses standard five-field cron syntax, and recent versions also accept intervals such as '30 seconds'.
2. Did it run, and what did it say?
select jobid, status, return_message, start_time, end_time
from cron.job_run_details
where start_time > now() - interval '5 days'
order by start_time desc
limit 20;- No rows at all: the job never started. Go to step 3.
- status = failed:
return_messageholds the Postgres error, for example a missing function, a permission error, orcanceling statement due to statement timeout. - status = succeeded but nothing happened: usually an HTTP call; see step 5.
3. Is the scheduler alive?
Supabase's debugging guide checks for the scheduler process:
select pid, application_name, backend_start, state, wait_event_type
from pg_stat_activity
where application_name ilike 'pg_cron scheduler';No row means the worker has stopped. Supabase's guide says to restart the database (a fast reboot from the project settings) to bring it back. Database resource pressure (connections, memory, disk) is a common reason it died, so check those reports too.
4. Is it the time zone?
Schedules are evaluated in UTC (GMT) unless the cron.timezone setting says otherwise. 0 9 * * * runs at 09:00 UTC, which is 14:30 at UTC+5:30. Convert your local time to UTC when you write the schedule.
5. Jobs that call an Edge Function
net.http_post() only queues the request and returns an id, so the cron run reports succeeded even when the function returns 401 or times out. Look at the HTTP result instead:
select id, status_code, timed_out, error_msg, left(content::text, 200) as body, created
from net._http_response
order by created desc
limit 20;A 401 means the request had no valid Authorization header. Store the key in Vault and read it inside the job instead of pasting it into the command:
select cron.schedule(
'nightly-report',
'0 3 * * *',
$$
select net.http_post(
url := (select decrypted_secret from vault.decrypted_secrets where name = 'project_url')
|| '/functions/v1/nightly-report',
headers := jsonb_build_object(
'Content-Type', 'application/json',
'Authorization', 'Bearer ' ||
(select decrypted_secret from vault.decrypted_secrets where name = 'anon_key')
),
body := jsonb_build_object('time', now()),
timeout_milliseconds := 5000
) as request_id;
$$
);timed_out = true means the function took longer than timeout_milliseconds (5 seconds by default in current pg_net; older versions used 2). Raise it, or have the function return quickly and continue the work in the background.
6. Limits and housekeeping
Supabase's guide says pg_cron supports up to 32 concurrent jobs, each using a database connection; many long jobs at the same minute compete for connections. cron.job_run_details is never cleaned up automatically, so schedule a cleanup:
select cron.schedule('cron-history-cleanup', '0 4 * * *',
$$delete from cron.job_run_details where end_time < now() - interval '7 days'$$);How to verify
Temporarily schedule the job every minute, wait two minutes, and check that job_run_details shows succeeded rows and, for HTTP jobs, that net._http_response shows status 200. Then put the real schedule back.
Related guides
- Supabase Database Webhooks and pg_net requests that never arrive – how to debug them
- Supabase Edge Function 401 “Invalid JWT” or “Missing authorization header”
- Supabase “canceling statement due to statement timeout” (57014) – fix the query, then the limit
- Supabase Edge Function returns 404 NOT_FOUND on the CORS preflight
More in Edge Functions, webhooks and APIs · all guides