PATH fix

Fix “psql is not recognized” on Windows — add PostgreSQL to PATH

The error means Windows cannot find psql.exe. Usually fixed by opening a new terminal after install. This guide covers all methods: GUI, cmd, and PowerShell.

What this error means

When you type psql in Command Prompt or PowerShell after installing PostgreSQL and see this:

PowerShell
psql : The term 'psql' is not recognized as the name of a cmdlet,
function, script file, or operable program.

It means Windows cannot find psql.exe because the PostgreSQL bin directory is not in your PATH. The fix is straightforward: add the bin folder to PATH and open a new terminal.

Open a new terminal window

The installer adds PostgreSQL to your PATH, but this change only affects new terminal sessions. Any Command Prompt or PowerShell that was open before or during the install will not see the update.

Close all open terminals and open a brand new Command Prompt or PowerShell window. Then run psql --version. This fixes the problem in 80% of cases.
cmd.exe — NEW window
C:\> psql --version
psql (PostgreSQL) 18.3

Add PostgreSQL to PATH via System Properties

  • 1

    Open Environment Variables

    Press Win+S → search Edit environment variables for your account → click it. Or: right-click This PC → Properties → Advanced system settings → Environment Variables.

  • 2

    Edit the Path variable

    In the User variables section, click PathEditNew.

  • 3

    Add the PostgreSQL bin folder

    Type the path to your PostgreSQL bin directory. For version 18 the default is:

    Path to add
    C:\Program Files\PostgreSQL\18\bin

    Adjust the version number if you installed 16 or 17. Click OK on all dialogs.

  • 4

    Open a new terminal and verify

    cmd.exe — new window
    C:\> psql --version
    psql (PostgreSQL) 18.3
    C:\> where psql
    C:\Program Files\PostgreSQL\18\bin\psql.exe

Add to PATH via Command Prompt

cmd.exe — run as Administrator
# Add permanently for the current user:
C:\> setx PATH "%PATH%;C:\Program Files\PostgreSQL\18\bin"
SUCCESS: Specified value was saved.
# Open a NEW terminal, then verify:
C:\> psql --version
psql (PostgreSQL) 18.3
setx does not affect the current terminal session. Always open a new Command Prompt after running setx.

Add to PATH via PowerShell

PowerShell
# Permanent fix for current user:
PS> [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\PostgreSQL\18\bin", "User")
# Open new PowerShell, verify:
PS> psql --version
psql (PostgreSQL) 18.3

PATH fix questions

I added to PATH but psql still not found
You must open a completely new terminal window. Closing and reopening a tab in an existing window is not enough — open a new application instance. Also check you added the correct version number in the path (e.g. 8\ not \).
Where is psql.exe located?
The default location is C:\Program Files\PostgreSQL\{version}in\psql.exe. If you changed the install directory during setup, look there instead. You can search with: dir /s /b "C:\Program Files\psql.exe"
Do I need to add the bin path to System variables or User variables?
User variables is sufficient for personal use. If you need psql to work for all users on the machine (including services and scheduled tasks), add it to System variables instead, which requires Administrator rights.
After Windows update, psql stopped working
Windows updates occasionally reset or trim PATH entries. Open Environment Variables and check that the PostgreSQL bin folder is still in the list. If missing, add it back using the GUI method above.

Need to connect to your database?

pgAdmin 4 provides a GUI alternative to psql.

pgAdmin 4 guide