PostgreSQL Field Guide

Install and connect to PostgreSQL

Choose a verifiable PostgreSQL 18 setup for Ubuntu, macOS, Windows, or containers

Choose the outcome first

OutcomeRecommended starting point
Learning, tests, CIDocker: pin the version and remove the whole environment cleanly
Persistent local developmentOS package manager or a trusted installer
ProductionA managed cloud service or team-managed repositories and configuration automation
Client onlyInstall psql/libpq client packages without running a local server

Installed does not mean internet-ready

Do not expose port 5432 publicly or turn pg_hba.conf into a global trust rule merely to connect. Verify locally first, then design networking, TLS, authentication, and least privilege.

Run the same verification everywhere

psql --version
psql -X "postgresql://postgres@localhost:5432/postgres" \
  -c "select current_setting('server_version'), current_database(), current_user;"

Client and server versions are separate. psql --version reports only the client; the SQL query reports the server you actually reached. When versions coexist, record executable path, port, and data directory.

Next, read psql connections and SSL, then create an application role that is not a superuser.

Last updated on

On this page