Install and use PostgreSQL locally for development

Practical notes for shipping software.

Databases & SQL Beginner 6 min read

First published: 2026-03-31 — part of the Utilhub editorial calendar. Bookmark /how-to/postgresql-install-local-development for updates as we refine commands for new OS and toolchain releases.

Install and use PostgreSQL locally for development — a practical guide for developers, scoped to Databases & SQL at a Beginner level. You will get vocabulary, a concrete path to first success, verification signals, and production-minded cautions you can apply on real systems.

Why run PostgreSQL locally?

Local Postgres matches production semantics more closely than embedded-only databases: real SQL, extensions, connection limits, and authentication flows. You catch migration issues and driver quirks before CI.

Install (pick your OS)

On Debian/Ubuntu, install the server package from your distro or use the official PostgreSQL APT repository for newer majors. On macOS, Homebrew (brew install postgresql@16) is common. On Windows, use the EnterpriseDB installer or WSL2 with Linux packages for parity with servers.

# Debian/Ubuntu (example; package names vary by release)
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl enable --now postgresql

Create a role and database

Do not develop as the superuser postgres unless you are applying global changes. Create a role with login and a database owned by that role.

sudo -u postgres createuser --interactive myapp
sudo -u postgres createdb -O myapp myapp_dev

Connect and sanity-check

psql -h localhost -U myapp -d myapp_dev -c "SELECT version();"

You should see a version string and no authentication errors. If connection fails, inspect pg_hba.conf for host lines and ensure the server listens on the right interface in postgresql.conf (listen_addresses).

Safe defaults for development

  • Use strong passwords even locally if your machine is shared or synced.
  • Keep extensions explicit: install only what you need.
  • Back up before running destructive experiments on shared dev databases.

Frequently asked questions

How do I report an issue with this guide?

Use the contact page and include your OS version and the command output you saw.

Can I reuse this internally?

Yes for internal playbooks; keep vendor trademarks and licenses in mind when redistributing.

Does this replace official vendor docs?

No—it compresses the path for busy builders. Follow links to PostgreSQL, Kubernetes, or cloud provider documentation for exhaustive references.

Related Utilhub guides

Browse the full how-to library with category and level filters.