Uninstalling PostgreSQL via Settings does not delete your databases. The data directory remains on disk until you manually delete it.
Uninstall steps
Completely remove PostgreSQL from Windows
- 1
Back up your databases first
# Back up all databases before uninstalling:C:\> pg_dumpall -U postgres -f C:\backup\final_backup.sqlThis is your last chance to export your data. Once the service is removed, you cannot use pg_dumpall. - 2
Stop the service
C:\> net stop postgresql-x64-18The postgresql-x64-18 service was stopped successfully. - 3
Uninstall via Settings or the EDB uninstaller
Settings → Apps → Installed apps → search PostgreSQL → click the three-dot menu → Uninstall. Or run the uninstaller directly:
# Run the EDB uninstaller directly:C:\> "C:\Program Files\PostgreSQL\18\uninstall-postgresql.exe" - 4
Delete the data directory to free disk space
The uninstaller leaves the data directory intact. Delete it manually to free disk space:
# Check size first:PS> (Get-ChildItem "C:\Program Files\PostgreSQL" -Recurse | Measure-Object Length -Sum).Sum / 1GB# Delete the entire PostgreSQL folder:PS> Remove-Item "C:\Program Files\PostgreSQL" -Recurse -Force - 5
Remove Windows Firewall rule
PS> Remove-NetFirewallRule -DisplayName "PostgreSQL 5432" - 6
Clean up PATH
Settings → System → Advanced system settings → Environment Variables → select Path under User variables → Edit → remove any PostgreSQL entries.
Remaining files
What the uninstaller leaves behind
| Location | Contents | Safe to delete? |
|---|---|---|
C:\Program Files\PostgreSQL\18\data | All your databases | Yes — after backing up |
%APPDATA%\postgresql | pgpass.conf, user config | Yes |
%APPDATA%\pgAdmin 4 | pgAdmin settings, saved queries | Yes |
| PATH environment variable | PostgreSQL bin path entry | Remove via Environment Variables |
FAQ
Uninstall questions
Does uninstalling PostgreSQL delete my databases?
No. The EDB uninstaller removes the server binaries and service registration but leaves the data directory completely untouched. Your databases are safe until you manually delete the data folder.
How do I uninstall multiple PostgreSQL versions?
Repeat the process for each version. Each major version has its own uninstaller at
C:\Program Files\PostgreSQL\{version}\uninstall-postgresql.exe and its own service name (postgresql-x64-16, postgresql-x64-17, etc.).PostgreSQL does not appear in Settings → Apps
Run the uninstaller directly from
C:\Program Files\PostgreSQL\{version}\uninstall-postgresql.exe. If the binary is missing, manually stop and delete the service: sc stop postgresql-x64-18 then sc delete postgresql-x64-18.