Skip to content
Guide · Install a database

How to Install PostgreSQL on Windows, Mac & Linux

PostgreSQL itself is free and open source, but the project does not ship its own Windows installer: postgresql.org points Windows and Mac users to an installer built and hosted by EDB, which bundles the server, pgAdmin 4 and the command line tools. This guide follows that installer screen by screen, then covers the Mac and Linux routes, putting psql on your PATH, creating a first database and the connection errors beginners hit most often.

Steps checked 8 October 2026 against the official documentation for each product. Versions covered: PostgreSQL 18.6 (current minor of the newest major version), pgAdmin 4 v9.18. Next review due April 2027. Installers, versions and download pages change; follow the official page if a step differs.
Short answer
  • The official PostgreSQL download page is postgresql.org/download; for Windows it links to the EDB interactive installer, which contains the server, pgAdmin 4, Stack Builder and the command line tools.
  • The current major version is PostgreSQL 18 (minor release 18.6). Each major version is supported for five years, and PostgreSQL 14 reaches end of life on 12 November 2026.
  • The installer asks for one password that is used for both the postgres database superuser and the Windows service account, and uses port 5432 by default.
  • The Windows installer does not add psql to your PATH; you add the bin folder yourself, for example C:\Program Files\PostgreSQL\18\bin.
  • On Linux, use your distribution's package or the PostgreSQL project's own apt or yum repository; on a Mac, the EDB installer, Postgres.app and Homebrew are all listed by postgresql.org.
How we know: Research-based: download options, installer screens, versions and error messages were checked against postgresql.org (download pages, versioning policy and documentation), EDB's installer documentation and download page, and pgadmin.org on 8 October 2026. We have not run these installers or commands for this guide, and no screenshots are shown; the screen names below are the ones EDB documents. If your installer differs, follow the official page.

PostgreSQL download: which package to choose

Start every PostgreSQL download at postgresql.org/download, which lists ready-to-use packages and installers by operating system as well as the source code. Do not download installers from mirror sites you do not recognise; the links below are the ones the PostgreSQL project itself publishes.

For the current release, the PostgreSQL versioning policy page shows 18.6 as the current minor version of PostgreSQL 18, first released on 25 September 2025 and supported until November 2030. A new major version arrives about once a year and each one is supported for five years, so a beginner should install the newest major version. If you are following a course or matching a production server, install the same major version as that server instead.

Official PostgreSQL install routes by platform (from postgresql.org)
PlatformRoute listed by postgresql.orgIncludes pgAdmin?
WindowsInteractive installer by EDB (graphical or silent), or a zip archive of the binaries for advanced usersYes, as an optional component
macOSInteractive installer by EDB, Postgres.app, Homebrew, MacPorts or FinkEDB installer only; otherwise install pgAdmin separately
Ubuntu and DebianDistribution package (apt install postgresql) or the PostgreSQL Apt Repository for other versionsNo; pgAdmin has its own APT packages
Red Hat, Rocky, AlmaLinux, FedoraDistribution package (dnf install postgresql-server) or the PostgreSQL Yum RepositoryNo; pgAdmin has its own RPM packages
DockerThe official postgres image (see the related PostgreSQL in Docker guide)No

PostgreSQL download for Windows: the EDB installer step by step

The Windows page on postgresql.org explains that the interactive installer is certified and hosted by EDB rather than by the PostgreSQL community servers, and that it includes the PostgreSQL server, pgAdmin and StackBuilder. On EDB's download page, pick the PostgreSQL version and the Windows x86-64 column; EDB marks 32-bit Windows as not supported for every current version.

EDB's documentation says you need administrator privileges to run the graphical wizard, and warns that it does not support all non-ASCII, multi-byte characters in user or machine names. Then, as documented by EDB:

  1. Double-click the installer (on some Windows versions, right-click it and choose Run as Administrator). The setup wizard opens on the Welcome screen; select Next.
  2. Installation Directory: accept the default or choose another folder.
  3. Select Components: keep PostgreSQL Server, pgAdmin 4 and Command Line Tools (psql, pg_dump, createdb and others). Stack Builder is optional.
  4. Data Directory: accept the default location for the data files, or choose another.
  5. Password: enter and retype a password. The same password is used for the postgres database superuser and the PostgreSQL service account, so store it safely.
  6. Port: the default listener port is 5432. Change it only if another PostgreSQL server already uses that port.
  7. Advanced Options: choose a locale; the default is the operating system locale.
  8. Review the Pre Installation Summary, select Next to install, then decide whether to launch Stack Builder at exit. Beginners can clear that check box and select Finish.

PostgreSQL then runs as a Windows service in the background, so it starts automatically with Windows. If you prefer an unattended setup, the postgresql.org Windows page notes the installer can also run in silent mode; EDB documents its command line parameters separately.

Add psql to PATH and connect for the first time

According to EDB, the installer does not modify the system path by default. To run psql from any command prompt, add the PostgreSQL bin folder yourself:

  1. Open System Properties on the Advanced tab (you can run SystemPropertiesAdvanced.exe).
  2. Select Environment Variables.
  3. Under System variables, select Path and then Edit.
  4. Add your installation directory followed by \bin, for example C:\Program Files\PostgreSQL\18\bin for PostgreSQL 18.

Open a new command prompt, so it picks up the changed PATH, and connect as the superuser. You are prompted for the password you chose in the installer:

Connect with psql as the postgres superuser (Windows command prompt)
psql -U postgres

Using pgAdmin instead of the command line

pgAdmin 4 is installed by the EDB installer when you leave its component selected. If you installed PostgreSQL another way, pgAdmin is available separately from pgadmin.org/download; the current Windows release is pgAdmin 4 v9.18 (17 September 2026), and v7.0 and later need Windows 10 or Windows Server 2016 or newer. For the pgAdmin side in detail, see the pgAdmin install guide and the pgAdmin review.

Installing PostgreSQL on macOS and Linux

macOS. postgresql.org lists the same EDB installer (graphical, command line or silent modes), plus Postgres.app, which it describes as a native macOS app that runs in the menu bar without an installer: open the app and the server is running, close it and the server shuts down. Homebrew is also listed; its formulae are named postgresql@NN, where NN is the major version. postgresql.org's own example uses version 15, so substitute the major version you want:

Homebrew example from postgresql.org (replace 15 with the major version you want)
brew install postgresql@15
Ubuntu: the distribution's own PostgreSQL package
apt install postgresql
Ubuntu: add the PostgreSQL Apt Repository, then install a specific major version
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt update
sudo apt install postgresql-18
RHEL, Rocky Linux, AlmaLinux and Fedora: distribution package, then initialise and enable it
dnf install postgresql-server
postgresql-setup --initdb
systemctl enable postgresql.service
systemctl start postgresql.service

Why the Linux version may be older than you expect

postgresql.org explains that each Linux distribution release "snapshots" one PostgreSQL version and supports it for the life of that release. On RHEL, Rocky and AlmaLinux 10, for example, the built-in package is PostgreSQL 16. If you need PostgreSQL 18, use the PostgreSQL project's Apt or Yum repository, which carries every supported version and provides updates through your normal package manager. On the Red Hat family the server is not initialised or started automatically, which is why the extra postgresql-setup and systemctl commands are needed.

Create your first database

The PostgreSQL tutorial creates a database with the createdb command and then opens it with psql. On Windows, add -U postgres to both commands so they connect as the superuser you created in the installer. Database names must start with a letter and are limited to 63 bytes.

Create a database called mydb and open it (Windows command prompt)
createdb -U postgres mydb
psql -U postgres mydb
First statements to try inside psql, from the PostgreSQL tutorial (PostgreSQL)
SELECT version();

CREATE TABLE weather (
    city            varchar(80),
    temp_lo         int,           -- low temperature
    temp_hi         int,           -- high temperature
    prcp            real,          -- precipitation
    date            date
);

INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');
SELECT * FROM weather;

Reading the psql prompt

The documentation explains that a prompt ending in => means an ordinary user, while =# means you are a database superuser, which is usual when you installed PostgreSQL yourself. Commands that start with a backslash are psql meta-commands rather than SQL; \q (or \quit) quits psql. psql only runs a statement once it sees the terminating semicolon, so a long CREATE TABLE can be typed over several lines.

Common PostgreSQL install and connection errors

Most first-day problems are one of the messages below, all documented in the PostgreSQL manual. CodeWithSQL's SQL error library currently covers SQL Server error codes; for PostgreSQL, the manual's own explanations are the reference.

PostgreSQL error messages beginners meet after installing
Message (shortened)What it meansWhat to check
createdb: command not foundThe tools are not on your PATH, or were not installed.Add the bin folder to PATH and open a new prompt, or call the tool with its full path.
connection to server ... failed: Connection refused / Is the server running ...?Nothing is listening at that address and port.Start the PostgreSQL service, and check the port (5432 by default) and host you connect to.
FATAL: password authentication failed for user "postgres"The server was reached but rejected the password.Use the password set in the installer's Password screen.
FATAL: role "name" does not existpsql defaults to your operating system user name, which is not a PostgreSQL role.Pass -U postgres or set the PGUSER environment variable.
FATAL: database "name" does not existWithout a database name, psql uses one with the same name as the user.Name an existing database, such as postgres or mydb.
could not bind IPv4 address ... Address already in useAnother server already uses the port.Stop the other server or choose another port during installation.

Next steps

With PostgreSQL running, work through the SQL beginner course using your new database, and practise with the SQL exercises. If you are still choosing an engine, compare MySQL vs PostgreSQL. If you would rather not install anything locally, see free PostgreSQL hosting options, or run the official image with Docker using the related guide below.

Frequently asked questions

Is PostgreSQL free to download?

Yes. PostgreSQL is open source and the packages and installers linked from postgresql.org/download cost nothing. The Windows and macOS interactive installer is built and hosted by EDB, a company, but the PostgreSQL inside it is the same community release.

Where is the official PostgreSQL download for Windows?

Go to postgresql.org/download, choose Windows, and follow the link to the interactive installer by EDB. Choose the Windows x86-64 package; 32-bit Windows is not supported by current versions.

Does the PostgreSQL installer include pgAdmin?

Yes. The EDB installer offers pgAdmin 4 as a component on the Select Components screen, alongside the server, Stack Builder and the command line tools. Linux packages do not include it; pgAdmin publishes its own APT and RPM packages.

What is the default PostgreSQL username and password?

The default superuser is postgres. There is no default password: the installer asks you to set one, and the same password is used for the PostgreSQL service account on Windows.

Why can Windows not find psql after installing PostgreSQL?

The EDB installer does not add PostgreSQL to the system PATH. Add the installation folder plus \bin (for example C:\Program Files\PostgreSQL\18\bin) to the Path variable and open a new command prompt.

Which PostgreSQL version should I install?

The newest major version, currently PostgreSQL 18, unless you need to match an existing server. Each major version receives fixes for five years; PostgreSQL 14 is supported only until 12 November 2026.

Sources

Checked 8 October 2026.

How we research guides: our editorial method. We link only to official downloads and never host installers.

Database installed?

Write your first queries with the free beginner course, then practise on real problems.