Skip to content

idle_session_timeout (integer)

This configuration parameter controls how long any user session may remain idle before being disconnected. Any session will time out if it has not run a statement for the specified length of time (regardless of open transactions). The default is 60 minutes (3600000 ms). Connections terminated due to idle_session_timeout will result in a sys.log_session state value of 25P04.

This parameter accepts settings with the following units: ms, s, min, h, and d.

Note: Running show idle_session_timeout as a superuser will always return unlimited (0), which is the superuser's setting.

You can modify this parameter with the following commands:

  • ALTER SYSTEM: Only sysadmin users can change these settings with this command, which applies to all sessions for all users. A configuration reload or database restart is required for the new values to take effect. For example:
alter system set idle_session_timeout to '2h';

show idle_session_timeout;
 idle_session_timeout 
----------------------
 1h
(1 row)
  • SET: Any user can change these settings with this command. The new value is applied only to the current user session. The next session for that user resets to the default value. For example:
set idle_session_timeout to 999999;

show idle_session_timeout;
 idle_session_timeout 
----------------------
 999999ms
(1 row)
  • ALTER ROLE: changes the settings only for the specified role. Restarting the database is not required, and the new settings are applied to all new sessions for that role. You do not have to be a sysadmin user to run this command, but you must have permissions to alter the role in question.
alter role bobr set idle_session_timeout to 999999;

show idle_session_timeout;
 idle_session_timeout 
----------------------
 1h
(1 row)

See also: idle_in_transaction_session_timeout.