Uninstall guide

Uninstall PostgreSQL on Windows — complete removal guide

Completely remove PostgreSQL from Windows. Back up databases first, stop the service, run the uninstaller, delete the data directory and clean up firewall rules and PATH.

Uninstalling PostgreSQL via Settings does not delete your databases. The data directory remains on disk until you manually delete it.

Completely remove PostgreSQL from Windows

  • 1

    Back up your databases first

    cmd.exe
    # Back up all databases before uninstalling:
    C:\> pg_dumpall -U postgres -f C:\backup\final_backup.sql
    This is your last chance to export your data. Once the service is removed, you cannot use pg_dumpall.
  • 2

    Stop the service

    cmd.exe — Administrator
    C:\> net stop postgresql-x64-18
    The 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:

    cmd.exe — Administrator
    # 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:

    PowerShell — Administrator
    # 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

    PowerShell — Administrator
    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.

What the uninstaller leaves behind

LocationContentsSafe to delete?
C:\Program Files\PostgreSQL\18\dataAll your databasesYes — after backing up
%APPDATA%\postgresqlpgpass.conf, user configYes
%APPDATA%\pgAdmin 4pgAdmin settings, saved queriesYes
PATH environment variablePostgreSQL bin path entryRemove via Environment Variables

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.

Reinstalling PostgreSQL?

Follow the full download and setup guide.

Download guide