-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-path-issues.html
More file actions
140 lines (139 loc) · 17.6 KB
/
fix-path-issues.html
File metadata and controls
140 lines (139 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Fix "psql is not recognized" on Windows — Add PostgreSQL to PATH</title>
<meta name="description" content="Solve psql is not recognized on Windows 10 and 11. Open a new terminal, add PostgreSQL bin to PATH via GUI, cmd or PowerShell. Step-by-step fix with verification.">
<link rel="canonical" href="https://postgre-sql.github.io/fix-path-issues.html">
<meta name="last-modified" content="2026-06-08">
<meta property="og:title" content="Fix "psql is not recognized" on Windows — Add PostgreSQL to PATH">
<meta property="og:description" content="Solve psql is not recognized on Windows 10 and 11. Open a new terminal, add PostgreSQL bin to PATH via GUI, cmd or PowerShell. Step-by-step fix with verification.">
<meta property="og:type" content="article">
<meta property="og:url" content="https://postgre-sql.github.io/fix-path-issues.html">
<meta property="og:image" content="https://postgre-sql.github.io/og-image.svg">
<meta name="twitter:card" content="summary_large_image">
<link rel="icon" href="/favicon.svg">
<link rel="stylesheet" href="/style.css">
</head>
<body>
<nav class="site-nav"><div class="wrap"><div class="nav-inner">
<a href="/index.html" class="nav-logo"><div class="nav-logo-mark">Pg</div><span class="nav-logo-name">PostgreSQL</span><span class="nav-logo-sub">for Windows</span></a>
<div class="nav-links">
<a href="/index.html" id="nl-home">Home</a>
<a href="/download-windows.html" id="nl-dl">Download</a>
<a href="/offline-installer.html" id="nl-off">Offline</a>
<a href="/configure-windows-service.html" id="nl-svc">Service</a>
<a href="/fix-path-issues.html" id="nl-path">PATH fix</a>
<a href="/pgadmin-windows.html" id="nl-pgadmin">pgAdmin</a>
<a href="/postgresql-windows-faq.html" id="nl-faq">FAQ</a>
</div>
<a href="/download-windows.html" class="nav-cta"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg> Download</a>
</div></div></nav>
<div class="page-hero"><div class="wrap">
<nav class="breadcrumb"><a href="/index.html">home</a> <span>/</span> <span>fix-path-issues</span></nav>
<span class="page-tag">PATH fix</span>
<h1>Fix “psql is not recognized” on Windows — <span>add PostgreSQL to PATH</span></h1>
<p class="page-lead">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.</p>
</div></div>
<div class="wrap"><div class="content-layout">
<main><div class="section" aria-labelledby="error-h2"><span class="section-label">The error</span><h2 id="error-h2">What this error means</h2>
<p>When you type <code>psql</code> in Command Prompt or PowerShell after installing PostgreSQL and see this:</p>
<div class="term"><div class="term-bar"><div class="term-dot" style="background:#ff5f56"></div><div class="term-dot" style="background:#ffbd2e"></div><div class="term-dot" style="background:#27c93f"></div><span class="term-label">PowerShell</span></div><div class="term-body"><div><span class="t-err">psql : The term 'psql' is not recognized as the name of a cmdlet,</span></div><div><span class="t-err">function, script file, or operable program.</span></div></div></div>
<p>It means Windows cannot find <code>psql.exe</code> because the PostgreSQL <code>bin</code> directory is not in your PATH. The fix is straightforward: add the bin folder to PATH and open a new terminal.</p>
</div>
<div class="section" aria-labelledby="fix1-h2"><span class="section-label">Fix 1 — most common</span><h2 id="fix1-h2">Open a new terminal window</h2>
<p>The installer adds PostgreSQL to your PATH, but this change only affects <strong>new</strong> terminal sessions. Any Command Prompt or PowerShell that was open before or during the install will not see the update.</p>
<div class="callout callout-ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg><span>Close all open terminals and open a brand new Command Prompt or PowerShell window. Then run <code>psql --version</code>. This fixes the problem in 80% of cases.</span></div>
<div class="term"><div class="term-bar"><div class="term-dot" style="background:#ff5f56"></div><div class="term-dot" style="background:#ffbd2e"></div><div class="term-dot" style="background:#27c93f"></div><span class="term-label">cmd.exe — NEW window</span></div><div class="term-body"><div><span class="t-p">C:\></span> <span class="t-c">psql --version</span></div><div><span class="t-v">psql (PostgreSQL) 18.3</span></div></div></div>
</div>
<div class="section" aria-labelledby="fix2-h2"><span class="section-label">Fix 2 — GUI method</span><h2 id="fix2-h2">Add PostgreSQL to PATH via System Properties</h2>
<ul class="steps">
<li class="step"><div class="step-n">1</div><div><h3>Open Environment Variables</h3><p>Press <strong>Win+S</strong> → search <strong>Edit environment variables for your account</strong> → click it. Or: right-click This PC → Properties → Advanced system settings → Environment Variables.</p></div></li>
<li class="step"><div class="step-n">2</div><div><h3>Edit the Path variable</h3><p>In the <strong>User variables</strong> section, click <strong>Path</strong> → <strong>Edit</strong> → <strong>New</strong>.</p></div></li>
<li class="step"><div class="step-n">3</div><div><h3>Add the PostgreSQL bin folder</h3><p>Type the path to your PostgreSQL bin directory. For version 18 the default is:</p>
<div class="term"><div class="term-bar"><div class="term-dot" style="background:#ff5f56"></div><div class="term-dot" style="background:#ffbd2e"></div><div class="term-dot" style="background:#27c93f"></div><span class="term-label">Path to add</span></div><div class="term-body"><div><span class="t-v">C:\Program Files\PostgreSQL\18\bin</span></div></div></div>
<p>Adjust the version number if you installed 16 or 17. Click OK on all dialogs.</p></div></li>
<li class="step"><div class="step-n">4</div><div><h3>Open a new terminal and verify</h3>
<div class="term"><div class="term-bar"><div class="term-dot" style="background:#ff5f56"></div><div class="term-dot" style="background:#ffbd2e"></div><div class="term-dot" style="background:#27c93f"></div><span class="term-label">cmd.exe — new window</span></div><div class="term-body"><div><span class="t-p">C:\></span> <span class="t-c">psql --version</span></div><div><span class="t-v">psql (PostgreSQL) 18.3</span></div><div><span class="t-p">C:\></span> <span class="t-c">where psql</span></div><div><span class="t-v">C:\Program Files\PostgreSQL\18\bin\psql.exe</span></div></div></div>
</div></li></ul>
</div>
<div class="section" aria-labelledby="fix3-h2"><span class="section-label">Fix 3 — command line</span><h2 id="fix3-h2">Add to PATH via Command Prompt</h2>
<div class="term"><div class="term-bar"><div class="term-dot" style="background:#ff5f56"></div><div class="term-dot" style="background:#ffbd2e"></div><div class="term-dot" style="background:#27c93f"></div><span class="term-label">cmd.exe — run as Administrator</span></div><div class="term-body"><div><span class="t-cm"># Add permanently for the current user:</span></div><div><span class="t-p">C:\></span> <span class="t-c">setx PATH "%PATH%;C:\Program Files\PostgreSQL\18\bin"</span></div><div><span class="t-v">SUCCESS: Specified value was saved.</span></div><div></div><div><span class="t-cm"># Open a NEW terminal, then verify:</span></div><div><span class="t-p">C:\></span> <span class="t-c">psql --version</span></div><div><span class="t-v">psql (PostgreSQL) 18.3</span></div></div></div>
<div class="callout callout-warn"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg><span><code>setx</code> does not affect the current terminal session. Always open a new Command Prompt after running setx.</span></div>
</div>
<div class="section" aria-labelledby="fix4-h2"><span class="section-label">Fix 4 — PowerShell</span><h2 id="fix4-h2">Add to PATH via PowerShell</h2>
<div class="term"><div class="term-bar"><div class="term-dot" style="background:#ff5f56"></div><div class="term-dot" style="background:#ffbd2e"></div><div class="term-dot" style="background:#27c93f"></div><span class="term-label">PowerShell</span></div><div class="term-body"><div><span class="t-cm"># Permanent fix for current user:</span></div><div><span class="t-p">PS></span> <span class="t-c">[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\PostgreSQL\18\bin", "User")</span></div><div></div><div><span class="t-cm"># Open new PowerShell, verify:</span></div><div><span class="t-p">PS></span> <span class="t-c">psql --version</span></div><div><span class="t-v">psql (PostgreSQL) 18.3</span></div></div></div>
</div>
<div class="section" aria-labelledby="faq-h2"><span class="section-label">FAQ</span><h2 id="faq-h2">PATH fix questions</h2><div class="faq">
<div class="faq-item"><details><summary>I added to PATH but psql still not found</summary><div class="faq-ans">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. <code>8\</code> not <code>\</code>).</div></details></div>
<div class="faq-item"><details><summary>Where is psql.exe located?</summary><div class="faq-ans">The default location is <code>C:\Program Files\PostgreSQL\{version}in\psql.exe</code>. If you changed the install directory during setup, look there instead. You can search with: <code>dir /s /b "C:\Program Files\psql.exe"</code></div></details></div>
<div class="faq-item"><details><summary>Do I need to add the bin path to System variables or User variables?</summary><div class="faq-ans">User variables is sufficient for personal use. If you need <code>psql</code> to work for all users on the machine (including services and scheduled tasks), add it to System variables instead, which requires Administrator rights.</div></details></div>
<div class="faq-item"><details><summary>After Windows update, psql stopped working</summary><div class="faq-ans">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.</div></details></div>
</div></div>
<div class="cta-banner"><div><h2>Need to connect to your database?</h2><p>pgAdmin 4 provides a GUI alternative to psql.</p></div><a href="/pgadmin-windows.html" class="btn-white"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>pgAdmin 4 guide</a></div>
<div style="margin-bottom:32px"><span class="section-label">Related guides</span><div class="rel-grid"><a href="/download-windows.html" class="rel-card"><div class="rel-title">Download guide →</div><div class="rel-sub">install PostgreSQL</div></a><a href="/pgadmin-windows.html" class="rel-card"><div class="rel-title">pgAdmin 4 →</div><div class="rel-sub">GUI alternative to psql</div></a><a href="/configure-windows-service.html" class="rel-card"><div class="rel-title">Windows service →</div><div class="rel-sub">service management</div></a></div></div></main>
<aside class="content-sidebar"><div class="sb-card"><div class="version-badge-label">Latest stable</div><div class="version-badge-val">18.3</div><div class="version-badge-sub">Released May 2026</div></div><div class="sb-card"><div class="sb-card-title">Install & setup</div><ul class="sb-links"><li><a href="/download-windows.html">Download PostgreSQL</a></li><li><a href="/offline-installer.html">Offline installer</a></li><li><a href="/configure-windows-service.html">Windows service</a></li><li><a href="/fix-path-issues.html" class="cur">Fix PATH / psql</a></li><li><a href="/pgadmin-windows.html">pgAdmin 4</a></li><li><a href="/install-postgresql-windows-server.html">Windows Server</a></li></ul></div><div class="sb-card"><div class="sb-card-title">Configuration</div><ul class="sb-links"><li><a href="/postgresql-config-windows.html">postgresql.conf</a></li><li><a href="/postgresql-port-5432.html">Port 5432</a></li><li><a href="/postgresql-allow-remote-connections.html">Remote connections</a></li><li><a href="/postgresql-password-windows.html">Reset password</a></li></ul></div><div class="sb-card"><div class="sb-card-title">Tools & help</div><ul class="sb-links"><li><a href="/psql-commands-windows.html">psql commands</a></li><li><a href="/pg-dump-restore-windows.html">Backup & restore</a></li><li><a href="/postgresql-python-windows.html">Python / psycopg2</a></li><li><a href="/odbc-driver-x64-x86.html">ODBC driver</a></li><li><a href="/postgresql-not-starting-windows.html">Service not starting</a></li><li><a href="/postgresql-uninstall-windows.html">Uninstall</a></li><li><a href="/postgresql-windows-faq.html">FAQ</a></li></ul></div></aside>
</div></div>
<footer class="site-footer"><div class="wrap">
<div class="footer-inner">
<div>
<div class="footer-logo"><div class="footer-logo-mark">Pg</div><span class="footer-logo-name">PostgreSQL for Windows</span></div>
<p class="footer-tagline">Unofficial Windows guide for PostgreSQL — download, install, configure, troubleshoot.</p>
</div>
<div>
<div class="footer-col-title">Install & setup</div>
<ul class="footer-links">
<li><a href="/download-windows.html">Download PostgreSQL</a></li>
<li><a href="/offline-installer.html">Offline installer</a></li>
<li><a href="/configure-windows-service.html">Windows service</a></li>
<li><a href="/fix-path-issues.html">Fix PATH / psql</a></li>
<li><a href="/pgadmin-windows.html">pgAdmin 4</a></li>
</ul>
</div>
<div>
<div class="footer-col-title">Configuration</div>
<ul class="footer-links">
<li><a href="/postgresql-config-windows.html">postgresql.conf</a></li>
<li><a href="/postgresql-port-5432.html">Port 5432</a></li>
<li><a href="/postgresql-allow-remote-connections.html">Remote connections</a></li>
<li><a href="/postgresql-password-windows.html">Reset password</a></li>
<li><a href="/install-postgresql-windows-server.html">Windows Server</a></li>
</ul>
</div>
<div>
<div class="footer-col-title">Tools & help</div>
<ul class="footer-links">
<li><a href="/psql-commands-windows.html">psql commands</a></li>
<li><a href="/pg-dump-restore-windows.html">Backup & restore</a></li>
<li><a href="/postgresql-not-starting-windows.html">Service not starting</a></li>
<li><a href="/postgresql-uninstall-windows.html">Uninstall</a></li>
<li><a href="/postgresql-windows-faq.html">FAQ</a></li>
</ul>
</div>
</div>
<div class="footer-bottom">
<p>Not affiliated with the PostgreSQL Global Development Group. Unofficial community guide.</p>
<p><strong>Affiliate disclosure:</strong> Download links may be partner links.</p>
</div>
</div></footer>
<div class="cookie-bar" id="cookieBar" style="display:none">
<p>We use Google Analytics for anonymous traffic data. <a href="/privacy.html">Privacy policy</a></p>
<div class="cookie-btns"><button class="cookie-accept" id="cookieAccept">Accept</button><button class="cookie-decline" id="cookieDecline">Decline</button></div>
</div>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MHLW57MR8Q"></script>
<script>
window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}
gtag('consent','default',{analytics_storage:'denied',ad_storage:'denied'});
gtag('js',new Date());gtag('config','G-MHLW57MR8Q',{anonymize_ip:true,send_page_view:false});
function grantGA(){gtag('consent','update',{analytics_storage:'granted'});gtag('event','page_view',{page_location:location.href,page_title:document.title})}
document.addEventListener('DOMContentLoaded',function(){
var bar=document.getElementById('cookieBar');
var c=localStorage.getItem('pg_consent');
if(!c){bar.style.display='flex'}else if(c==='1'){grantGA()}
document.getElementById('cookieAccept').addEventListener('click',function(){localStorage.setItem('pg_consent','1');grantGA();bar.style.display='none'});
document.getElementById('cookieDecline').addEventListener('click',function(){localStorage.setItem('pg_consent','0');bar.style.display='none'});
});
</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"HowTo","name":"Fix psql is not recognized on Windows","description":"How to add PostgreSQL to PATH on Windows to fix the psql not recognized error.","step":[{"@type":"HowToStep","position":1,"name":"Open new terminal","text":"Close all terminals and open a new Command Prompt or PowerShell"},{"@type":"HowToStep","position":2,"name":"Add to PATH via GUI","text":"Environment Variables > User Path > New > C:\\Program Files\\PostgreSQL\\18\\bin"},{"@type":"HowToStep","position":3,"name":"Verify","text":"psql --version should show PostgreSQL 18.3"}]}</script>
<script>var el=document.getElementById("nl-path");if(el)el.classList.add("active");</script>
</body></html>