(Azure) How do I completely remove PostgreSQL after a failed/unfinished uninstall?

David Nunez Rivas 0 Reputation points
2025-08-23T18:46:17.79+00:00

Details: I tried uninstalling PostgreSQL from my Windows system, but the process seems to have failed or got stuck. Some services and files are still left behind, and I cannot remove PostgreSQL properly.

What I already tried: uninstalling from "Apps & Features," manually deleting folders, and checking services, but the PostgreSQL service still appears.

User's image

Azure Database for PostgreSQL
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vinodh247 40,056 Reputation points MVP Volunteer Moderator
    2025-08-24T06:25:56.9133333+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    It looks like your pgsql uninstall process was incomplete, leaving behind services, folders, and registry entries on your Windows system. To clean it up completely, start by stopping and deleting any remaining PostgreSQL services. Open cmd as an administrator, run sc query | findstr /i postgresql to list active pgsql services, and if you see any, stop them using net stop <service-name> and delete them with sc delete <service-name>. Next, manually delete any leftover folders such as C:\Program Files\PostgreSQL, C:\Program Files (x86)\PostgreSQL, or pgsql related folders inside your user’s AppData directories. After that, open the registry editor and carefully remove pgsql related entries under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services, HKEY_LOCAL_MACHINE\SOFTWARE, and HKEY_CURRENT_USER\SOFTWARE. Also, check for any pgsql related environment variables and remove them. Once everything is cleaned up, restart your system to ensure all changes are applied. If the system still gives issues, you can reinstall the same version of pgsql and then perform a clean uninstall. As for the azure notification you shared, it indicates that the pgsql flexible server named pgserverlab was not found, which typically means it was already deleted or never existed. You can safely ignore that part, as it is unrelated to the cleanup on your Windows machine.

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.


  2. VRISHABHANATH PATIL 2,305 Reputation points Microsoft External Staff Moderator
    2025-08-25T12:08:00.0033333+00:00

    Hi @David Nunez Rivas

    Here’s a clear and concise step-by-step guide to fully remove PostgreSQL from your system:

    1. Stop and uninstall PostgreSQL services
      1. Open Command Prompt as Administrator
      2. List active PostgreSQL services: sc query | findstr /i postgresql
      3. Stop each PostgreSQL service net stop <service-name>
      4. Delete each PostgreSQL service sc delete <service-name>
    2. Delete Remaining Files: Manually check and remove any leftover PostgreSQL folders from the following locations:
      1. C:\Program Files\PostgreSQL
      2. C:\Program Files (x86)\PostgreSQL
      3. C:\Users<YourUsername>\AppData\Local\PostgreSQL
    3. Clean Up Windows Registry (PostgreSQL Removal)
      1. Open the Registry Editor (regedit via Run dialog).
      2. Carefully delete PostgreSQL-related entries from:
        1. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
        2. HKEY_LOCAL_MACHINE\SOFTWARE
        3. HKEY_CURRENT_USER\SOFTWARE ⚠️ Caution: Editing the registry can impact system stability. Proceed only if you're confident.
    4. Check Environment Variables
      1. Go to System Properties → Advanced → Environment Variables and ensure no PostgreSQL-related variables remaining.
    5. Restart Your Computer
      1. After removing all PostgreSQL components, restart your system to apply the changes fully.

    Additionally, kindly refer the below document -

    https://www.enterprisedb.com/docs/supported-open-source/postgresql/uninstalling/

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.