-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-path-issues.html
More file actions
423 lines (403 loc) · 24.4 KB
/
fix-path-issues.html
File metadata and controls
423 lines (403 loc) · 24.4 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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/11 by adding PostgreSQL bin to PATH. UI steps, CMD and PowerShell methods, verification, and troubleshooting." />
<link rel="canonical" href="https://postgre-sql.github.io/fix-path-issues.html" />
<meta name="last-modified" content="2026-05-01T13:06:51Z" />
<meta name="robots" content="index,follow" />
<meta name="theme-color" content="#336791" />
<!-- Open Graph -->
<meta property="og:type" content="article" />
<meta property="og:title" content="Fix “psql is not recognized” on Windows — Add PostgreSQL to PATH" />
<meta property="og:description" content="Add PostgreSQL bin to PATH on Windows. Step-by-step UI, CMD, and PowerShell instructions with quick verification." />
<meta property="og:url" content="https://postgre-sql.github.io/fix-path-issues.html" />
<meta property="og:site_name" content="PostgreSQL for Windows" />
<meta property="og:image" content="https://postgre-sql.github.io/og-image.png" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Fix “psql is not recognized” on Windows" />
<meta name="twitter:description" content="Add PostgreSQL bin to PATH with UI, CMD, or PowerShell." />
<meta name="twitter:image" content="https://postgre-sql.github.io/og-image.png" />
<!-- Icons -->
<link rel="icon" href="https://postgre-sql.github.io/favicon.svg" type="image/svg+xml" />
<link rel="alternate icon" href="https://postgre-sql.github.io/favicon.ico" />
<link rel="apple-touch-icon" href="https://postgre-sql.github.io/apple-touch-icon.png" />
<style>
:root{
--bg:#F8FAFC; --panel:#FFFFFF; --text:#0F172A; --muted:#334155; --primary:#336791; --primary-600:#2b5a75; --primary-700:#244a60; --accent:#3E7BB6; --success:#2F855A; --warning:#B7791F; --border:#E2E8F0; --focus:#F59E0B; --shadow:0 2px 10px rgba(15,23,42,.08);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0; color:var(--text); background:var(--bg); font:16px/1.55 system-ui,-apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji"}
a{color:var(--primary)}
a:focus, button:focus{outline:3px solid var(--focus); outline-offset:2px}
header{position:sticky; top:0; z-index:50; background:rgba(255,255,255,.9); backdrop-filter:saturate(180%) blur(8px); border-bottom:1px solid var(--border)}
.wrap{max-width:1100px; margin:0 auto; padding:0 16px}
.topbar{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 0}
.brand{display:flex; align-items:center; gap:10px; color:var(--primary-700); text-decoration:none; font-weight:700}
.brand svg{width:28px;height:28px}
nav ul{list-style:none; margin:0; padding:0; display:flex; gap:14px; flex-wrap:wrap}
nav a{display:inline-flex; align-items:center; gap:6px; text-decoration:none; color:var(--muted); padding:8px 10px; border-radius:8px}
nav a:hover{background:#eef2f7; color:var(--primary-700)}
.breadcrumbs{font-size:14px; color:var(--muted); padding:10px 0}
.breadcrumbs a{text-decoration:none; color:inherit}
.hero{background:linear-gradient(180deg, #fff 0%, #f3f7fb 100%); border-bottom:1px solid var(--border)}
.hero .inner{display:grid; grid-template-columns:1.1fr .9fr; gap:24px; padding:34px 0}
.hero h1{font-size:clamp(26px,3.3vw,38px); line-height:1.15; margin:8px 0 10px}
.hero p.sub{color:var(--muted); margin:0 0 18px}
.btn{appearance:none; border:0; border-radius:10px; padding:12px 16px; display:inline-flex; align-items:center; gap:10px; cursor:pointer; font-weight:700; text-decoration:none}
.btn-primary{background:var(--primary); color:#fff}
.btn-primary:hover{background:var(--primary-600)}
.btn-ghost{background:transparent; color:var(--primary-700); border:2px solid var(--primary-600)}
.btn-ghost:hover{background:#e8f0f9}
.cta-row{display:flex; gap:12px; flex-wrap:wrap}
.note{display:flex; align-items:center; gap:8px; color:var(--muted); font-size:14px; margin-top:10px}
.section{padding:30px 0}
.section h2{margin:0 0 14px; font-size:22px}
.card-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:16px}
.card{background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:16px; box-shadow:var(--shadow)}
.card h3{margin:0 0 8px; font-size:18px}
.card p{margin:0; color:var(--muted)}
.list{margin:10px 0 0; padding-left:18px}
.kbd{display:inline-block; padding:.1em .45em; border:1px solid #CBD5E1; border-bottom-width:2px; border-radius:6px; background:#fff; font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size:.95em}
footer{margin-top:24px; border-top:1px solid var(--border); background:#fff}
.footer-inner{display:grid; grid-template-columns:1fr 1fr; gap:16px; padding:18px 0}
.muted{color:var(--muted)}
.disclaimer{background:#fff; border:1px dashed var(--border); padding:14px; border-radius:12px; color:var(--muted)}
.mobile-cta{position:fixed; bottom:12px; left:12px; right:12px; display:none; z-index:30}
.mobile-cta .inner{background:#10263a; border-radius:14px; padding:10px; display:flex; justify-content:space-between; align-items:center; gap:10px; color:#e6f1fa; box-shadow:0 8px 22px rgba(0,0,0,.25)}
.mobile-cta .inner .btn{padding:10px 14px}
/* Cookie banner */
.cookie-banner{position:fixed; z-index:60; inset:auto 12px 12px 12px; background:#fff; border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow); display:none}
.cookie-content{padding:14px; display:grid; grid-template-columns:1fr auto; gap:12px; align-items:start}
.cookie-actions{display:flex; gap:8px; flex-wrap:wrap}
.cookie-banner .btn{padding:10px 12px}
/* Responsive */
@media (max-width: 900px){
.hero .inner{grid-template-columns:1fr}
.card-grid{grid-template-columns:1fr 1fr}
.footer-inner{grid-template-columns:1fr}
}
@media (max-width: 640px){
.card-grid{grid-template-columns:1fr}
.mobile-cta{display:block}
}
</style>
<!-- SVG Sprite -->
<svg xmlns="http://www.w3.org/2000/svg" style="position:absolute;width:0;height:0;overflow:hidden" aria-hidden="true">
<symbol id="icon-download" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 3a1 1 0 011 1v8.586l2.293-2.293a1 1 0 111.414 1.414l-4.001 4a1 1 0 01-1.412 0l-4.001-4a1 1 0 011.414-1.414L11 12.586V4a1 1 0 011-1z"/>
<path d="M4 15a1 1 0 011-1h2a1 1 0 010 2H6v3h12v-3h-1a1 1 0 110-2h2a1 1 0 011 1v4a2 2 0 01-2 2H6a2 2 0 01-2-2v-4z"/>
</symbol>
<symbol id="icon-external" viewBox="0 0 24 24" fill="currentColor"><path d="M14 3a1 1 0 000 2h3.586l-8.293 8.293a1 1 0 001.414 1.414L19 6.414V10a1 1 0 002 0V4a1 1 0 00-1-1h-6z"/><path d="M5 6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5a1 1 0 10-2 0v5H5V8h5a1 1 0 100-2H5z"/></symbol>
<symbol id="icon-check" viewBox="0 0 24 24" fill="currentColor"><path d="M20.285 6.708a1 1 0 010 1.414l-9.192 9.192a1 1 0 01-1.414 0L3.715 11.55a1 1 0 111.414-1.414l5.1 5.1 8.485-8.485a1 1 0 011.571-.042z"/></symbol>
<symbol id="icon-info" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2a10 10 0 100 20 10 10 0 000-20zm0 6a1.25 1.25 0 110-2.5A1.25 1.25 0 0112 8zm1 9h-2v-6h2v6z"/></symbol>
<symbol id="icon-warning" viewBox="0 0 24 24" fill="currentColor"><path d="M12.882 2.773l9.02 15.625A2 2 0 0120.236 22H3.764a2 2 0 01-1.666-3.602l9.02-15.625a2 2 0 013.764 0zM11 9v5h2V9h-2zm1 8a1.25 1.25 0 100-2.5A1.25 1.25 0 0012 17z"/></symbol>
<symbol id="icon-close" viewBox="0 0 24 24" fill="currentColor"><path d="M6.225 4.811a1 1 0 011.414 0L12 9.172l4.361-4.361a1 1 0 111.414 1.414L13.414 10.586l4.361 4.361a1 1 0 01-1.414 1.414L12 12l-4.361 4.361a1 1 0 01-1.414-1.414l4.361-4.361-4.361-4.361a1 1 0 010-1.414z"/></symbol>
</svg>
<!-- GA4 base tag -->
<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 });
</script>
<!-- Schema.org JSON-LD -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": "https://postgre-sql.github.io/"},
{"@type": "ListItem", "position": 2, "name": "Fix PATH Issues", "item": "https://postgre-sql.github.io/fix-path-issues.html"}
]
},
{
"@type": "SoftwareApplication",
"name": "PostgreSQL for Windows",
"operatingSystem": "Windows 11, Windows 10 (64-bit)",
"applicationCategory": "DatabaseApplication",
"softwareVersion": "18.3-3",
"downloadUrl": "https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe",
"offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD", "category": "free"},
"publisher": {"@type": "Organization", "name": "Unofficial PostgreSQL for Windows Guide", "url": "https://postgre-sql.github.io/"}
},
{
"@type":"HowTo",
"name":"Fix 'psql is not recognized' on Windows",
"totalTime":"PT5M",
"step": [
{"@type":"HowToStep","name":"Locate PostgreSQL bin","text":"Find the bin folder, e.g., C:/Program Files/PostgreSQL/18/bin (adjust version).","url":"https://postgre-sql.github.io/fix-path-issues.html#locate"},
{"@type":"HowToStep","name":"Open Environment Variables","text":"Press Win+R → sysdm.cpl → Advanced → Environment Variables.","url":"https://postgre-sql.github.io/fix-path-issues.html#env"},
{"@type":"HowToStep","name":"Edit PATH","text":"Edit your User (or System) PATH and add the bin path. Move it above duplicates if needed.","url":"https://postgre-sql.github.io/fix-path-issues.html#edit"},
{"@type":"HowToStep","name":"Restart terminal","text":"Close and reopen Command Prompt/PowerShell to load new PATH.","url":"https://postgre-sql.github.io/fix-path-issues.html#restart"},
{"@type":"HowToStep","name":"Verify","text":"Run 'where psql' and 'psql --version' to confirm.","url":"https://postgre-sql.github.io/fix-path-issues.html#verify"}
]
},
{
"@type": "FAQPage",
"mainEntity": [
{"@type": "Question", "name": "Should I edit User PATH or System PATH?", "acceptedAnswer": {"@type":"Answer","text":"For a single user, editing the User PATH is sufficient. Use System PATH if you want all users and services to see psql."}},
{"@type": "Question", "name": "Do I need to reboot after editing PATH?", "acceptedAnswer": {"@type":"Answer","text":"No full reboot is required, but you must close and reopen terminals and apps to load the updated PATH."}},
{"@type": "Question", "name": "Multiple PostgreSQL versions installed?", "acceptedAnswer": {"@type":"Answer","text":"Keep only one bin folder in PATH or ensure the desired version appears first to avoid version conflicts."}},
{"@type": "Question", "name": "PowerShell vs CMD?", "acceptedAnswer": {"@type":"Answer","text":"Both work. Ensure the updated PATH is visible in the shell session you opened after the change."}}
]
}
]
}
</script>
</head>
<body>
<header>
<div class="wrap topbar">
<a class="brand" href="https://postgre-sql.github.io/" aria-label="PostgreSQL for Windows — home">
<svg aria-hidden="true"><use href="#icon-check"></use></svg>
<span>PostgreSQL for Windows</span>
</a>
<nav aria-label="Primary navigation">
<ul>
<li><a href="https://postgre-sql.github.io/download-windows.html"><svg width="16" height="16" aria-hidden="true"><use href="#icon-download"></use></svg> Download</a></li>
<li><a href="https://postgre-sql.github.io/offline-installer.html">Offline installer</a></li>
<li><a href="https://postgre-sql.github.io/odbc-driver-x64-x86.html">ODBC x64/x86</a></li>
<li><a href="https://postgre-sql.github.io/configure-windows-service.html">Service</a></li>
<li><a href="https://postgre-sql.github.io/fix-path-issues.html">PATH</a></li>
<li><a href="https://postgre-sql.github.io/migrate-from-older-versions.html">Migrate</a></li>
</ul>
</nav>
</div>
</header>
<div class="wrap breadcrumbs" aria-label="Breadcrumb">
<a href="https://postgre-sql.github.io/">Home</a> · <span>Fix PATH Issues</span>
</div>
<section class="hero">
<div class="wrap inner">
<div>
<h1>Fix “psql is not recognized” on Windows</h1>
<p class="sub">Add the PostgreSQL <code>bin</code> folder to your PATH, restart your terminal, and verify with <code>where psql</code>. Works on Windows 10/11.</p>
<div class="cta-row">
<a class="btn btn-primary" href="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" target="_blank" rel="noopener" aria-label="Download PostgreSQL 18.3-3 for Windows (64-bit)"
data-download-url="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" data-download-file="postgresql-18.3-3-windows-x64.exe">
<svg width="20" height="20" aria-hidden="true"><use href="#icon-download"></use></svg>
<span>Get the installer</span>
</a>
<a class="btn btn-ghost" href="https://postgre-sql.github.io/download-windows.html">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-external"></use></svg>
<span>Install guide</span>
</a>
</div>
<div class="note" role="note">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-info"></use></svg>
<span><strong>Tip:</strong> Typical path is <code>C:\Program Files\PostgreSQL\18\bin</code> (adjust version).</span>
</div>
</div>
<div>
<div class="card">
<h3>Quick answer</h3>
<ul class="list">
<li id="locate">Find the PostgreSQL <strong>bin</strong> folder.</li>
<li id="env">Open <span class="kbd">sysdm.cpl</span> → Advanced → Environment Variables.</li>
<li id="edit">Edit PATH and <strong>add</strong> the bin path (move above duplicates).</li>
<li id="restart">Restart Command Prompt/PowerShell.</li>
<li id="verify">Run <code>where psql</code> and <code>psql --version</code>.</li>
</ul>
</div>
</div>
</div>
</section>
<main class="wrap">
<section class="section">
<h2>Method A — GUI (recommended)</h2>
<div class="card">
<ol class="list">
<li>Press <span class="kbd">Win</span> + <span class="kbd">R</span>, type <span class="kbd">sysdm.cpl</span>, press Enter.</li>
<li>Go to <strong>Advanced</strong> → click <strong>Environment Variables…</strong>.</li>
<li>Under <strong>User variables</strong>, select <strong>Path</strong> → <strong>Edit…</strong>.</li>
<li>Click <strong>New</strong> and paste your PostgreSQL <strong>bin</strong> path, e.g., <code>C:\\Program Files\\PostgreSQL\\18\\bin</code>.</li>
<li>Use the arrows to move it <strong>above</strong> any older PostgreSQL entries.</li>
<li>Click OK on all dialogs to apply. Close and reopen your terminal/app.</li>
</ol>
</div>
</section>
<section class="section">
<h2>Method B — Command Prompt (permanent)</h2>
<div class="card">
<p class="muted">Run Command Prompt as your user (or as Administrator if you want to edit the System PATH). Replace the path with your version.</p>
<ul class="list">
<li>Append to <strong>User PATH</strong>:
<div><code>setx PATH "%PATH%;C:\\Program Files\\PostgreSQL\\18\\bin"</code></div>
</li>
<li>Append to <strong>System PATH</strong> (requires elevated CMD):
<div><code>setx /M PATH "%PATH%;C:\\Program Files\\PostgreSQL\\18\\bin"</code></div>
</li>
<li>Close and reopen the terminal, then verify:
<div><code>where psql</code> and <code>psql --version</code></div>
</li>
</ul>
</div>
</section>
<section class="section">
<h2>Method C — PowerShell (per-user)</h2>
<div class="card">
<p class="muted">Use PowerShell to add to the <strong>User PATH</strong>. Reopen apps after applying.</p>
<ul class="list">
<li>Show current User PATH:
<div><code>[Environment]::GetEnvironmentVariable("Path", "User")</code></div>
</li>
<li>Add PostgreSQL bin:
<div><code>$p = [Environment]::GetEnvironmentVariable("Path","User"); if (-not $p.EndsWith(";")) { $p += ";" }; $p += "C:\\Program Files\\PostgreSQL\\18\\bin"; [Environment]::SetEnvironmentVariable("Path", $p, "User")</code></div>
</li>
<li>Reopen PowerShell/CMD, then verify with <code>where psql</code>.</li>
</ul>
</div>
</section>
<section class="section">
<h2>Troubleshooting — quick answers</h2>
<div class="card-grid">
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Still not recognized</h3>
<p>Close and reopen the terminal/app. Ensure the bin path is correct and appears before older PostgreSQL paths.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Multiple versions</h3>
<p>Keep only one PostgreSQL bin in PATH, or place the desired version first. Verify with <code>where psql</code>.</p>
</div>
<div class="card">
<h3><svg width="16" height="16" aria-hidden="true"><use href="#icon-warning"></use></svg> Admin vs user PATH</h3>
<p>Editing System PATH requires elevation. If you only changed User PATH, services won’t see it. Use System PATH for service contexts.</p>
</div>
</div>
</section>
<section class="section">
<h2>Related guides</h2>
<div class="card-grid">
<a class="card" href="https://postgre-sql.github.io/download-windows.html" style="text-decoration:none; color:inherit">
<h3>Download & Install</h3>
<p>Step-by-step setup on Windows 10/11.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/offline-installer.html" style="text-decoration:none; color:inherit">
<h3>Offline Installer</h3>
<p>Install PostgreSQL without internet access.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/configure-windows-service.html" style="text-decoration:none; color:inherit">
<h3>Configure Windows Service</h3>
<p>Service account, startup type, and logs.</p>
</a>
<a class="card" href="https://postgre-sql.github.io/odbc-driver-x64-x86.html" style="text-decoration:none; color:inherit">
<h3>ODBC Drivers (x64/x86)</h3>
<p>Choose the right psqlODBC and set up a DSN.</p>
</a>
</div>
</section>
<section class="section">
<div class="disclaimer">
<p><strong>Disclaimer:</strong> This is an unofficial resource. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. Links may include affiliate tracking.</p>
</div>
</section>
</main>
<div class="mobile-cta" aria-hidden="true">
<div class="inner">
<span>Need the PostgreSQL installer?</span>
<a class="btn btn-primary" href="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" target="_blank" rel="noopener" data-download-url="https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe" data-download-file="postgresql-18.3-3-windows-x64.exe">
<svg width="18" height="18" aria-hidden="true"><use href="#icon-download"></use></svg>
<span>Download</span>
</a>
</div>
</div>
<footer>
<div class="wrap footer-inner">
<div>
<p class="muted">Author: Senior Web Developer & Technical Writer • Unofficial site</p>
<p class="muted">Last updated: <time id="lastUpdated" datetime="">--</time></p>
</div>
<div>
<p class="muted">Need help? Read the <a href="https://postgre-sql.github.io/download-windows.html">Install guide</a> or check <a href="https://postgre-sql.github.io/odbc-driver-x64-x86.html">ODBC drivers</a>.</p>
</div>
</div>
</footer>
<!-- Cookie banner -->
<div id="cookieBanner" class="cookie-banner" role="dialog" aria-live="polite" aria-label="Cookie consent">
<div class="cookie-content">
<div>
<strong>Cookies & analytics</strong>
<p class="muted" style="margin:6px 0 0">We use minimal analytics to improve this guide. Choose Accept to enable Google Analytics, or Decline to stay anonymous.</p>
</div>
<div class="cookie-actions">
<button class="btn btn-primary" id="cookieAccept">Accept</button>
<button class="btn btn-ghost" id="cookieDecline">Decline</button>
<button class="btn" id="cookieClose" aria-label="Close cookie banner"><svg width="16" height="16" aria-hidden="true"><use href="#icon-close"></use></svg> Close</button>
</div>
</div>
</div>
<script>
(function(){
const FILE_URL = 'https://get.enterprisedb.com/postgresql/postgresql-18.3-3-windows-x64.exe';
const FILE_NAME = 'postgresql-18.3-3-windows-x64.exe';
// Bind GA download events to all direct download anchors
function bindDownloadEvents(){
document.querySelectorAll('a[data-download-url]').forEach(a => {
a.addEventListener('click', function(){
try {
gtag('event','file_download', {
event_category: 'downloads',
event_label: a.getAttribute('data-download-file') || FILE_NAME,
file_url: a.getAttribute('data-download-url') || FILE_URL
});
} catch(e) {}
}, {passive:true});
});
}
// Cookie consent banner logic
const banner = document.getElementById('cookieBanner');
const btnAccept = document.getElementById('cookieAccept');
const btnDecline = document.getElementById('cookieDecline');
const btnClose = document.getElementById('cookieClose');
function showBanner(){ banner.style.display='block'; }
function hideBanner(){ banner.style.display='none'; }
function applyStoredConsent(){
const saved = localStorage.getItem('ga_consent');
if(saved === 'granted'){
gtag('consent','update', {'analytics_storage':'granted','ad_storage':'denied'});
hideBanner();
} else if(saved === 'denied'){
gtag('consent','update', {'analytics_storage':'denied','ad_storage':'denied'});
hideBanner();
} else {
const closed = sessionStorage.getItem('cookie_banner_closed');
if(!closed) showBanner();
}
}
btnAccept.addEventListener('click', function(){
localStorage.setItem('ga_consent','granted');
gtag('consent','update', {'analytics_storage':'granted','ad_storage':'denied'});
hideBanner();
});
btnDecline.addEventListener('click', function(){
localStorage.setItem('ga_consent','denied');
gtag('consent','update', {'analytics_storage':'denied','ad_storage':'denied'});
hideBanner();
});
btnClose.addEventListener('click', function(){
sessionStorage.setItem('cookie_banner_closed','1');
hideBanner();
});
// Update visible last updated and meta
const last = new Date(document.lastModified || '2026-05-01T13:06:51Z');
const lastISO = last.toISOString();
const lastEl = document.getElementById('lastUpdated');
if(lastEl){ lastEl.textContent = last.toLocaleDateString(undefined, {year:'numeric', month:'short', day:'2-digit'}); lastEl.setAttribute('datetime', lastISO); }
const metaLM = document.querySelector('meta[name="last-modified"]');
if(metaLM){ metaLM.setAttribute('content', lastISO); }
bindDownloadEvents();
applyStoredConsent();
})();
</script>
</body>
</html>