Config guide

PostgreSQL configuration on Windows — postgresql.conf & pg_hba.conf

Configure PostgreSQL on Windows through postgresql.conf (server settings) and pg_hba.conf (authentication rules). Covers key settings, memory tuning, editing and applying changes.

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

psql
-- Find data directory from psql:
postgres=# SHOW data_directory;
data_directory
----------------------------------
C:/Program Files/PostgreSQL/18/data
-- Or find config file directly:
postgres=# SHOW config_file;
C:/Program Files/PostgreSQL/18/data/postgresql.conf

Essential postgresql.conf settings for Windows

SettingDefaultWhat it does
port5432TCP port PostgreSQL listens on
max_connections100Maximum simultaneous client connections
shared_buffers128MBMemory for shared buffer cache (set to 25% of RAM)
work_mem4MBMemory per sort/hash operation
listen_addresseslocalhostWhich IPs to accept connections on
log_directorylogLog file subdirectory under data dir
log_filenamepostgresql-%Y-%m-%d.logLog file naming pattern

How to edit postgresql.conf and apply changes

PowerShell — Administrator
# Open postgresql.conf in Notepad:
PS> notepad "C:\Program Files\PostgreSQL\18\data\postgresql.conf"
# After saving, reload config without restart:
PS> & "C:\Program Files\PostgreSQL\18\bin\pg_ctl.exe" reload -D "C:\Program Files\PostgreSQL\18\data"
# Or from psql:
postgres=# SELECT pg_reload_conf();
pg_reload_conf
t
Some settings (like 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.

pg_hba.conf format
# TYPE DATABASE USER ADDRESS METHOD
local all all scram-sha-256
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256
# Allow specific user from specific IP:
host mydb myuser 192.168.1.0/24 scram-sha-256

After editing pg_hba.conf, reload the configuration with SELECT pg_reload_conf(); in psql.

Recommended memory settings for Windows

System RAMshared_bufferswork_memmax_connections
4 GB1GB16MB50
8 GB2GB32MB100
16 GB4GB64MB200
32 GB8GB128MB300
On Windows, 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
First try 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?
In psql: 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.

Need to allow remote connections?

Configure pg_hba.conf and firewall for network access.

Remote connections