Timeouts | Supabase Docs
Skip to content Updated Nov 18, 2026 Dashboard and Client queries have a max-configurable timeout of 60 seconds. For longer transactions, use the shared pooler or direct connections . Change Postgres timeout You can change the Postgres timeout at the: Session level Function level Global level Role level Session level Session level settings persist only for the duration of the connection. Set the session timeout by running: 1 set statement_timeout = ' 10min ' ; Because it applies to sessions only, it can only be used with connections through the shared pooler in session mode (port 5432) or a direct connection.
It cannot be used in the Dashboard, with the Supabase Client API, nor with Supavisor in Transaction mode (port 6543). This is most often used for single, long running, administrative tasks, such as creating an HSNW index. Once the setting is implemented, you can view it by executing: 1 SHOW statement_timeout; See the full guide on changing session timeouts . Function level This works with the Database REST API when called from the Supabase client libraries: 1 create or replace function myfunc () 2 returns void as $$ 3 select pg_sleep( 3 ); -- simulating some long-running process 4 $$ 5 language sql 6 set statement_timeout TO ' 4s ' ; -- set custom timeout This is mostly for recurring functions that need a special exemption for runtimes.
Role level This sets the timeout for a specific role. The default role timeouts are: anon : 3s authenticated : 8s service_role : none (defaults to the authenticator role's 8s timeout if unset) postgres : none (capped by default global timeout to be 2min) Run the following query to change a role's timeout: 1 alter role example_role set statement_timeout = ' 10min ' ; -- could also use seconds '10s' If you are changing the timeout for the Supabase Client API calls, you will need to reload PostgREST to reflect the timeout changes by running the following script: 1 NOTIFY pgrst, ' reload config ' ; Unlike global settings, the result cannot be checked with SHOW statement_timeout .
Instead, run: 1 select 2 rolname, 3 rolconfig 4 from pg_roles 5 where 6 rolname in ( 7 ' anon ' , 8 ' authenticated ' , 9 ' postgres ' , 10 ' service_role ' 11 -- ,<ANY CUSTOM ROLES> 12 ); Global level This changes the statement timeout for all roles and sessions without an explicit timeout already set. 1 alter database postgres set statement_timeout TO ' 4s ' ; Check if your changes took effect: 1 show statement_timeout; Although not necessary, if you are uncertain if a timeout has been applied, you can run a quick test: 1 create or replace function myfunc () 2 returns void as $$ 3 select pg_sleep( 601 ); -- simulating some long-running process 4 $$ 5 language sql ; Identifying timeouts The Supabase Dashboard contains tools to help you identify timed-out and long-running queries .
If a query fails with a statement timeout, see Canceling statement due to statement timeout . Query timeout logs Go to the Explorer , select Run SQL , choose query source Logs , set a time range, and run the following query to identify timed-out events ( statement timeout ) and queries that successfully run for longer than 10 seconds ( duration ). 1 select 2 timestamp , 3 event_message, 4 log_attributes [ 'parsed.error_severity' ] as error_severity, 5 log_attributes [ 'parsed.user_name' ] as user_name, 6 log_attributes [ 'parsed.query' ] as query, 7 log_attributes [ 'parsed.detail' ] as detail, 8 log_attributes [ 'parsed.hint' ] as hint, 9 log_attributes [ 'parsed.sql_state_code' ] as sql_state_code, 10 log_attributes [ 'parsed.backend_type' ] as backend_type 11 from logs 12 where 13 source = ' postgres_logs ' 14 and match (event_message, ' duration|statement timeout ' ) 15 -- (OPTIONAL) MODIFY OR REMOVE 16 and log_attributes [ 'parsed.user_name' ] = ' authenticator ' -- <--------CHANGE 17 order by timestamp desc 18 limit 100 ; Using the Query Performance page Go to the Query Performance page and filter by relevant role and query speeds.
This only identifies slow-running but successful queries. Unlike the logs, it does not show you timed-out queries. Understanding roles in logs Each API server uses a designated user for connecting to the database: Role API/Tool supabase_admin Used by Realtime and for project configuration authenticator PostgREST supabase_auth_admin Auth supabase_storage_admin Storage supabase_replication_admin Synchronizes Read Replicas postgres Supabase Dashboard and External Tools (e.g., Prisma, SQLAlchemy, PSQL...) Custom roles External Tools (e.g., Prisma, SQLAlchemy, PSQL...) Filter by the parsed.user_name field to only retrieve logs made by specific users: 1 -- find events based on role/server 2 ... query 3 where 4 -- find events from the relevant role 5 log_attributes [ 'parsed.user_name' ] = ' <ROLE> ' Is this helpful?
AI tools Connect your AI agent Ask ChatGPT Ask Claude Prefer on Google