← Back to all services
Databases

PostgreSQL Default Port & Configuration

postgresql systemctl: postgresql

Advanced open-source relational database. ACID compliant, extensible, excellent for complex queries.

🔌 Default Port

5432
tcp
PostgreSQL protocol

📦 Installation Command

apt install postgresql postgresql-contrib postgresql-client

⚙️ Configuration Files

  • /etc/postgresql/16/main/postgresql.conf
  • /etc/postgresql/16/main/pg_hba.conf
  • /etc/postgresql/16/main/pg_ident.conf

📂 Default Directories

  • config: /etc/postgresql/16/main
  • data: /var/lib/postgresql/16/main
  • logs: /var/log/postgresql
  • socket: /var/run/postgresql

🔐 Default Credentials

Username:postgres
Password:N/A (peer auth by default)
💡 Uses peer authentication - login via: sudo -u postgres psql. Set password: ALTER USER postgres PASSWORD 'newpassword';

📌 Dependencies

libpq5postgresql-common

⚠️ Conflicts

N/A (unique port) Port: cockroachdb (if configured on 5432)

✅ Works With

php-fpmpgadmin4pgbouncerpostgis

🛡️ Security Notes

Configure pg_hba.conf properly (reject trust auth), use md5/scram-sha-256, enable SSL, use connection pooling (pgbouncer) for high traffic

❓ Frequently Asked Questions

What is PostgreSQL default port?
PostgreSQL uses port 5432 by default.
What is PostgreSQL default username?
The default superuser is 'postgres' with peer authentication on Ubuntu.
Where is PostgreSQL config file?
Config files are in /etc/postgresql/{version}/main/ including postgresql.conf and pg_hba.conf.