PostgreSQL Config Generator

Generate production-oriented postgresql.conf and pg_hba.conf files with security hardening, performance tuning, and robust replication settings.

PostgreSQL Version

Connection Settings

Use '*' for all interfaces (requires strict pg_hba.conf), or specific IPs like '10.0.0.5'.

Too many connections exhaust RAM. Above 500, use PgBouncer.

Memory Settings

Typically 25% of total system RAM (e.g., 2GB, 8GB).

Typically 50-75% of total RAM. Helps the query planner.

Memory used per sort operation. Don't set too high if max_connections is large.

WAL & Checkpoints

Soft limit for WAL size. If you write heavily, increase to 4GB-16GB.

Autovacuum

Logging & Telemetry

Log queries taking longer than X ms. Set to 1000 for 1 second. -1 disables.

e.g., 'pg_stat_statements, auto_explain'

Security & SSL

Client Authentication (pg_hba.conf)

Leave blank for 'local' type

Leave blank for 'local' type

Leave blank for 'local' type

Leave blank for 'local' type

postgresql.conf
1

Overview

PostgreSQL is one of the most advanced open-source relational databases. However, its default configuration out-of-the-box is notoriously conservative, designed to run on machines with very little RAM. Generating a production-oriented postgresql.conf and pg_hba.conf is critical to ensure high performance, security, and data integrity.

Memory Tuning

Optimize shared_buffers, work_mem, and effective_cache_size for your exact RAM.

Security & HBA

Lock down network access with CIDR rules and modern SCRAM-SHA-256 encryption.

WAL & Replication

Configure checkpoint targets and WAL buffers for high throughput and safe replication.

Production Checklist

  • Firewall: If listen_addresses = '*', ensure an external firewall (AWS Security Group, UFW) strictly blocks port 5432 from the public internet.
  • SSL: Always enable SSL (ssl = on) if clients connect over untrusted networks.
  • Backups: Configuration is not a backup strategy. Ensure pg_dump or WAL archiving (like pgBackRest) is scheduled and tested.
  • Monitoring: Enable pg_stat_statements in shared_preload_libraries to monitor slow queries.