off
is strongly recommended for production environments. Enable only in controlled development or testing networks where automatic discovery provides tangible benefits. Always disable in internet-facing or production deployments.app-dev-db
instead of production-database-with-sensitive-data
.localhost
for single-machine setups, specific internal IPs for private networks, or *
only in controlled environments with other security measures. Never use *
in internet-facing deployments.100
is often too low for production. Calculate based on (available_ram - shared_buffers - other_overhead) / 10MB
. Typically 200-500
for medium systems, but use connection pooling (PgBouncer) for applications requiring thousands of connections.5432
is acceptable for most environments. Consider changing to a non-standard port in internet-facing deployments to reduce automated attack surface. Ensure firewall rules and client applications are updated accordingly.2-5
connections depending on your administrative needs. Ensure appropriate roles are granted the pg_use_reserved_connections privilege for emergency access.3
is reasonable for most environments. Maintain at least 2-3 reserved connections for superusers to ensure reliable administrative access during emergencies./tmp
or /var/run/postgresql
. Use a dedicated directory with restricted permissions for enhanced security. Ensure the directory exists and has proper ownership by the PostgreSQL user.postgres
or a dedicated database user group. Create a specific group for database users and assign appropriate membership to control socket access.0777
(read/write/execute for all) is permissive. Set to 0770
(group read/write/execute only) or 0700
(user only) for better security. Use 0770
when multiple users in a specific group need access, and 0700
for single-user setups.Properly configuring connection settings is essential for both database security and performance.
With pghealth, you can:
Start optimizing your PostgreSQL connection settings today with our free trial β no installation or commitment required.