How to fix Cannot change runtime parameter in PostgreSQL
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';- Check the parameter context
- For postmaster parameters, restart the server
- For sighup parameters, reload the configuration
- For user/superuser parameters, verify permissions
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
- 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
- Parameter has no session or transaction-level context support
How to fix "Cannot change runtime parameter"
Query pg_settings to understand when the parameter can be changed:
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.
If context is "postmaster", edit postgresql.conf with the desired setting and restart PostgreSQL:
# Edit the configuration file
sudo nano /etc/postgresql/VERSION/main/postgresql.conf
# Restart PostgreSQL
sudo systemctl restart postgresqlCommon postmaster parameters: max_connections, shared_buffers, port, superuser_reserved_connections.
If context is "sighup", edit postgresql.conf and reload without restarting:
# 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:
sudo systemctl reload postgresqlIf context allows "superuser" or "user" changes, verify you have the correct role:
-- 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:
GRANT SET ON PARAMETER parameter_name TO username;For PostgreSQL 9.4+, ALTER SYSTEM provides a safer way to change parameters persistently:
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
- ๐PostgreSQL Official Documentation
- ๐postgresql.org - Setting Parameters(Official Docs)
- ๐postgresql.org - SET Command(Official Docs)
- ๐postgresql.org - ALTER SYSTEM(Official Docs)
- ๐postgresql.org - Runtime Configuration(Official Docs)