Method A — GUI (recommended)
- Press Win + R, type sysdm.cpl, press Enter.
- Go to Advanced → click Environment Variables….
- Under User variables, select Path → Edit….
- Click New and paste your PostgreSQL bin path, e.g.,
C:\\Program Files\\PostgreSQL\\18\\bin. - Use the arrows to move it above any older PostgreSQL entries.
- 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 psqlandpsql --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.