Blueprints · Docker & Databases
Production
10 min · PostgreSQL 17
PostgreSQL listen localhost
Stages listen_addresses and a SCRAM reminder. It does not rewrite a live pg_hba.conf.
Why this should not be public
Port 5432 is scanned constantly for weak passwords on the postgres role. With listen_addresses = '*' and a permissive pg_hba.conf, one guessed password is the whole database.
Baked-in protections
- listen_addresses is localhost
- The live pg_hba.conf is not replaced
- The server is not reloaded
Step 1 · conf
postgresql.conf snippet
/root/portgate-blueprints/postgres-listen.conf
Merge listen_addresses into the real config. Do not replace pg_hba from this file.
listen_addresses = 'localhost' password_encryption = scram-sha-256
Step 2 · bash
Read-only check
/root/portgate-blueprints/postgres-listen-check.sh
Prints status. It does not change the service.
#!/bin/sh set -eu ss -tulpn | grep 5432 || echo "Nothing is listening on 5432."