PostgreSQL configuration files on Windows
PostgreSQL on Windows is configured through two main files located in the data directory: postgresql.conf controls server behaviour (memory, connections, logging, port) and pg_hba.conf controls client authentication (who can connect and how). Both files are plain text and can be edited with any text editor.
The default data directory is C:\Program Files\PostgreSQL\18\data. Always back up both files before editing.
Locate postgresql.conf and pg_hba.conf
Essential postgresql.conf settings for Windows
| Setting | Default | What it does |
|---|---|---|
port | 5432 | TCP port PostgreSQL listens on |
max_connections | 100 | Maximum simultaneous client connections |
shared_buffers | 128MB | Memory for shared buffer cache (set to 25% of RAM) |
work_mem | 4MB | Memory per sort/hash operation |
listen_addresses | localhost | Which IPs to accept connections on |
log_directory | log | Log file subdirectory under data dir |
log_filename | postgresql-%Y-%m-%d.log | Log file naming pattern |
How to edit postgresql.conf and apply changes
port and shared_buffers) require a full service restart to take effect, not just a reload.Configure client authentication with pg_hba.conf
pg_hba.conf controls which hosts can connect, which users, to which databases, and with what authentication method. Each line is a rule. Lines are checked top to bottom — first match wins.
After editing pg_hba.conf, reload the configuration with SELECT pg_reload_conf(); in psql.
Recommended memory settings for Windows
| System RAM | shared_buffers | work_mem | max_connections |
|---|---|---|---|
| 4 GB | 1GB | 16MB | 50 |
| 8 GB | 2GB | 32MB | 100 |
| 16 GB | 4GB | 64MB | 200 |
| 32 GB | 8GB | 128MB | 300 |
shared_buffers above 512MB may require adjusting the max_map_count equivalent. The EDB installer handles this automatically for recommended values.Configuration questions
Changes to postgresql.conf not taking effect
SELECT pg_reload_conf(); in psql. If the setting shows the old value in SHOW setting_name;, it requires a full service restart: net stop postgresql-x64-18 && net start postgresql-x64-18.How do I check what the current value of a setting is?
SHOW setting_name; for example SHOW max_connections;. To see all settings: SELECT name, setting, unit FROM pg_settings ORDER BY name;postgresql.conf vs ALTER SYSTEM — which to use?
ALTER SYSTEM writes to postgresql.auto.conf which overrides postgresql.conf. Both are valid. ALTER SYSTEM is more convenient but edits only one setting at a time. For bulk changes, editing postgresql.conf directly is clearer.