How to increase max connections for Postgres?
frank-embleton
PROOP

a month ago

I can see this has been answered previously:

https://station.railway.com/questions/how-to-increase-the-max-connections-on-p-5f3ce16e which referred to this answer https://station.railway.com/feedback/ui-for-tuning-postgres-configuration-57239a76

However in the current UI I cannot see the start command, and if I use the sample command referenced in the workaround:

wrapper.sh postgres --port=5432 -c 'max_connections=6715' -c 'shared_buffers=1GB' -c 'work_mem=32MB'

Then I still see max connections = 100. The start command is not present on the service after re-deploy.

What is the way to manage this in 2026?

Solved

5 Replies

Railway
BOT

a month ago

The current way to modify Postgres configuration is by using the ALTER SYSTEM SQL command rather than the start command. You can run ALTER SYSTEM SET max_connections = '500'; (or your desired value), followed by SELECT pg_reload_conf();, and then restart the deployment from the 3-dot menu. Full details are in our PostgreSQL docs. Note that max_connections specifically requires a restart to take effect, so the pg_reload_conf() alone won't apply it - the restart is the critical step.


Status changed to Awaiting User Response Railway 28 days ago


Railway

The current way to modify Postgres configuration is by using the `ALTER SYSTEM` SQL command rather than the start command. You can run `ALTER SYSTEM SET max_connections = '500';` (or your desired value), followed by `SELECT pg_reload_conf();`, and then restart the deployment from the 3-dot menu. Full details are in our [PostgreSQL docs](https://docs.railway.com/databases/postgresql#modifying-the-postgres-configuration). Note that `max_connections` specifically requires a restart to take effect, so the `pg_reload_conf()` alone won't apply it - the restart is the critical step.

frank-embleton
PROOP

a month ago

@Railway team: This works, but it is not documented


Status changed to Awaiting Railway Response Railway 28 days ago


Railway
BOT

a month ago

Glad it worked! We appreciate the feedback, and we'll note that the older community posts referencing the start command approach are causing confusion. For future reference, the current method is documented in the Modifying the Postgres configuration section of our Postgres docs.


Status changed to Awaiting User Response Railway 28 days ago


Status changed to Solved Railway 28 days ago


frank-embleton
PROOP

a month ago

max_connections is not documented:

Modifying the Postgres configuration

You can modify the Postgres configuration by using the ALTER SYSTEM command.

ALTER SYSTEM SET shared_buffers = '2GB';
ALTER SYSTEM SET effective_cache_size = '6GB';
ALTER SYSTEM SET maintenance_work_mem = '512MB';
ALTER SYSTEM SET work_mem = '32MB';
ALTER SYSTEM SET max_worker_processes = '8';
ALTER SYSTEM SET max_parallel_workers_per_gather = '4';
ALTER SYSTEM SET max_parallel_workers = '8';

-- Reload the configuration to save the changes
SELECT pg_reload_conf();

After running the SQL, you will need to restart the deployment for the changes to take effect.

You can restart the deployment by clicking the Restart button in the deployment's 3-dot menu.


Status changed to Awaiting Railway Response Railway 28 days ago


Railway
BOT

a month ago

You're right, max_connections is not listed in the examples on that docs page. We'll pass this along to get it added to the Postgres configuration section, along with a note that it requires a restart (not just pg_reload_conf()) to take effect.


Status changed to Awaiting User Response Railway 28 days ago


Status changed to Solved Railway 28 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...