How to fix Cannot change runtime parameter in PostgreSQL

PostgreSQLINTERMEDIATEMEDIUMUpdated Dec 28, 2025ยท 168 views

This error occurs when attempting to modify a PostgreSQL configuration parameter that cannot be changed at runtime. Most parameters require server restart or configuration file changes rather than SET commands.

Quick fix

Fixes Cannot change runtime parameter

SELECT name, setting, context FROM pg_settings WHERE name = 'your_parameter';
  1. Check the parameter context
  2. For postmaster parameters, restart the server
  3. For sighup parameters, reload the configuration
  4. For user/superuser parameters, verify permissions
postgresql โ€” error
SELECT name, setting, context FROM pg_settings WHERE name = 'your_parameter';
Cannot change runtime parameter

What this error means

PostgreSQL runtime parameters have different "context" levels that determine when they can be modified. Some parameters have a "postmaster" context, meaning they can only be set at server startup. Others have a "sighup" context, requiring a configuration reload. A few parameters are restricted to superuser modification. When you attempt to change a parameter with SET or UPDATE pg_settings, PostgreSQL checks if the parameter is allowed to change in your current context (session, transaction, or superuser-only). If the parameter context does not allow runtime changes, PostgreSQL raises the "Cannot change runtime parameter" error.

Typical symptoms

  • ERROR: parameter "X" cannot be changed now when running SET commands
  • UPDATE pg_settings fails for certain parameters
  • Changes made to postgresql.conf do not take effect without server restart
  • Superuser restrictions prevent certain users from modifying parameters

Common causes

  1. Attempting to change a postmaster-context parameter with SET (requires server restart)
  2. Using SET for a sighup-context parameter (requires pg_reload_conf() or reload via config file)
  3. Non-superuser attempting to change a parameter restricted to superusers
  4. Parameter has no session or transaction-level context support

How to fix "Cannot change runtime parameter"

1Check the parameter context

Query pg_settings to understand when the parameter can be changed:

sql
SELECT name, setting, context FROM pg_settings WHERE name = 'your_parameter';

The context column will show: postmaster, sighup, superuser, user, or other values that indicate when changes are allowed.

2For postmaster parameters, restart the server

If context is "postmaster", edit postgresql.conf with the desired setting and restart PostgreSQL:

bash
# Edit the configuration file
sudo nano /etc/postgresql/VERSION/main/postgresql.conf

# Restart PostgreSQL
sudo systemctl restart postgresql

Common postmaster parameters: max_connections, shared_buffers, port, superuser_reserved_connections.

3For sighup parameters, reload the configuration

If context is "sighup", edit postgresql.conf and reload without restarting:

bash
# Edit the configuration file
sudo nano /etc/postgresql/VERSION/main/postgresql.conf

# Reload configuration (PostgreSQL stays running)
psql -U postgres -c "SELECT pg_reload_conf();"

Or use the system command:

bash
sudo systemctl reload postgresql
4For user/superuser parameters, verify permissions

If context allows "superuser" or "user" changes, verify you have the correct role:

sql
-- Check current user
SELECT current_user;

-- For superuser-only parameters, connect as a superuser
psql -U postgres

-- Then set the parameter
SET parameter_name TO value;

If you need to grant SET privileges to other users, the superuser can do:

sql
GRANT SET ON PARAMETER parameter_name TO username;
5Use ALTER SYSTEM for persistent changes

For PostgreSQL 9.4+, ALTER SYSTEM provides a safer way to change parameters persistently:

sql
ALTER SYSTEM SET parameter_name = value;

-- Then reload configuration
SELECT pg_reload_conf();

ALTER SYSTEM writes to postgresql.auto.conf, which PostgreSQL reads in addition to postgresql.conf. For postmaster parameters, the server must still be restarted.

Advanced notes

Understanding parameter contexts is critical for effective PostgreSQL administration. The "postmaster" context parameters control fundamental server behavior (connections, memory allocation, network port) and must be set before the server starts, as changing them would require reorganizing core server structures. The "sighup" context parameters can be reloaded via SIGHUP signal without stopping the server, making them more flexible. For high-availability deployments, use ALTER SYSTEM combined with pg_reload_conf() to manage configuration changes across replicas. In containerized environments (Docker, Kubernetes), setting postmaster parameters via command-line arguments to the postgres process avoids the need to mount and edit configuration files.

Frequently asked questions

What does "Cannot change runtime parameter" mean?
PostgreSQL runtime parameters have different "context" levels that determine when they can be modified. Some parameters have a "postmaster" context, meaning they can only be set at server startup. Others have a "sighup" context, requiring a configuration reload.
How do I fix "Cannot change runtime parameter"?
This error occurs when attempting to modify a PostgreSQL configuration parameter that cannot be changed at runtime. Most parameters require server restart or configuration file changes rather than SET commands.
What causes "Cannot change runtime parameter"?
Attempting to change a postmaster-context parameter with SET (requires server restart) Using SET for a sighup-context parameter (requires pg_reload_conf() or reload via config file) Non-superuser attempting to change a parameter restricted to superusers
Is the "Cannot change runtime parameter" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading