PostgreSQL for Windows

Fix “psql is not recognized” on Windows

Add the PostgreSQL bin folder to your PATH, restart your terminal, and verify with where psql. Works on Windows 10/11.

Tip: Typical path is C:\Program Files\PostgreSQL\18\bin (adjust version).

Quick answer

  • Find the PostgreSQL bin folder.
  • Open sysdm.cpl → Advanced → Environment Variables.
  • Edit PATH and add the bin path (move above duplicates).
  • Restart Command Prompt/PowerShell.
  • Run where psql and psql --version.

Method A — GUI (recommended)

  1. Press Win + R, type sysdm.cpl, press Enter.
  2. Go to Advanced → click Environment Variables….
  3. Under User variables, select PathEdit….
  4. Click New and paste your PostgreSQL bin path, e.g., C:\\Program Files\\PostgreSQL\\18\\bin.
  5. Use the arrows to move it above any older PostgreSQL entries.
  6. Click OK on all dialogs to apply. Close and reopen your terminal/app.

Method B — Command Prompt (permanent)

Run Command Prompt as your user (or as Administrator if you want to edit the System PATH). Replace the path with your version.

  • Append to User PATH:
    setx PATH "%PATH%;C:\\Program Files\\PostgreSQL\\18\\bin"
  • Append to System PATH (requires elevated CMD):
    setx /M PATH "%PATH%;C:\\Program Files\\PostgreSQL\\18\\bin"
  • Close and reopen the terminal, then verify:
    where psql and psql --version

Method C — PowerShell (per-user)

Use PowerShell to add to the User PATH. Reopen apps after applying.

  • Show current User PATH:
    [Environment]::GetEnvironmentVariable("Path", "User")
  • Add PostgreSQL bin:
    $p = [Environment]::GetEnvironmentVariable("Path","User"); if (-not $p.EndsWith(";")) { $p += ";" }; $p += "C:\\Program Files\\PostgreSQL\\18\\bin"; [Environment]::SetEnvironmentVariable("Path", $p, "User")
  • Reopen PowerShell/CMD, then verify with where psql.

Troubleshooting — quick answers

Still not recognized

Close and reopen the terminal/app. Ensure the bin path is correct and appears before older PostgreSQL paths.

Multiple versions

Keep only one PostgreSQL bin in PATH, or place the desired version first. Verify with where psql.

Admin vs user PATH

Editing System PATH requires elevation. If you only changed User PATH, services won’t see it. Use System PATH for service contexts.

Related guides

Disclaimer: This is an unofficial resource. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. Links may include affiliate tracking.