7

I am getting the following error when trying to install PostgreSQL on my Windows 10 Machine (x64). Can anyone help me troubleshoot? Many thanks! Error screenshot below:

https://i.sstatic.net/bvOGU.png

14 Answers 14

5

I tried installing both postgresql-10.10-1-windows-x64 and postgresql-11.5-1-windows-x64 on Windows 10 x64. Got the similar error.

Try downloading postgresql-11.2-1-windows-x64 from the following official link: https://get.enterprisedb.com/postgresql/postgresql-11.2-1-windows-x64.exe

Hope this helps.

1

This happened to me as well. Turned out I couldn't use a Domain user (even though it is an admin on the local machine). I had to log in as a local admin user, and then the installation worked. This is very weird.

1

I tried installing Postgresql-9.5.19.1-windows-x64 version (downloaded from official page) on Windows 10 x64 and it gave me the same error. I tried executing it with administrator privileges, giving permissions to the temp folder, moving temp folder to another location but nothing worked...

The solution for me was using a different version of 9.5: PostgreSQL-9.5.2-1-windows-x64.

1

This error happened to me to on PostgreSQL version 11.2

I elaborated in a Stackoverflow post as answer to 'Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432?' a solution. I mentioned this question thread with answers as being the solution to this error.

But in short it is what you all are saying: reinstall.

But it can be the same or a different version in my experience.

My explanation:

The general thought/assumptions:

It looks like it is pgAdmin (probably version 4) or your admin rights or one of the files mentioned above (postgresql.conf and/or pg_hba.conf).

I had the same error and even a password error (for the correct password) after being a step further by some todo's and fixes that helped other people in previous versions;

But none of them worked for postgresql version 12.3 and/or postgresql version 11.8

Solution versions:

The only thing that helped after two hours was: As explained in this post: 'PostgreSQL Install fail on Windows 10 (icalcs error/acces denied)' on the superuser forum of StackExchange:

  • Uninstall en reinstall postgresql. The official version provided by EDB through this link: postgresql.org/download; Or try a different version if you are sure this one doesn't work for you. Therefor head to the 'File Browser'of Postgresql: here
  • After reinstall, start pgAdmin from the Start Menu (scroll for the folder and the correct related pgAdmin; an older version could still hang around in the shortcuts and won't start).

Note: You can keep your data map so nothing is lost!

In my case e.g.: I removed the /data folder from the (Windows 10) [Drive]/Program Files/PostgreSQL/11 and as soon as I uninstalled version 11.2 and reinstalled (earlier removed 12) version 12: when I started pgAdmin4 my former servers ([nameA] and [PostgreSQL 11] and databases ánd the new server [PostgreSQL 12] were there! And the connection was reestablished

Tried:

Earlier tried solutions that did not work in my case:

1

If you have issues with permissions either after installations or after reinstalling postgres you might find help here.

Make sure you install the correct version for the data folder you have, you can check the version in that data folder under file named PG_VERSION.

  1. Install postgres with random data directory. If it doesn't work with old data directory and you get errors about permissions or stuff like icacls then pick a fresh folder and proceed with this post.
  2. Go to registry editor and then find something like HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\postgresql-x64-11 <- version you installed change imagepath to reflect the data directory "C:\Program Files\PostgreSQL\11\bin\pg_ctl.exe" runservice -N "postgresql-x64-11" -D "{DATA_DIRECTORY like d:/db}" -w
  3. At this point the service might not even start, but check just in case it is magically working at this stage. It won't log anything or throw any errors so don't worry, if you do everything right it will work.
  4. Right click the data folder then go to Properites -> Security tab -> Advanced button
  5. Toggle the checkbox on the bottom "Replace all child object perm[..]"
  6. Press Add, and select principal on top, then type in the big box NETWORK SERVICE To make sure it works try pressing check names, it should underscore it. Then press OK, set all permissions to it. Then OK, OK, OK. You should leave the file properties approving everything.

If steps 4-6 throw out permissions errors read step 7 /

  1. Try running postgres. If for some reason you cant run postgres at this point. Then run command-line as an administrator, and type in icacls "{DATA_FOLDER}" /reset /T this will clear all the permissions that are there no matter what they are. Postgres install ought to be doing that but it's bugged in some versions. As it was in mine.
  2. Now you can try running postgres service.
  3. At this point PG Admin didn't really work but I managed to login using the psql.exe and I've dumped all the data. pg_dump -U {USERNAME} {DATABASE} > {FILENAME.EXT} Then I've uninstalled postgres, restarted PC, then installed the newest version and I've recovered the dump.
0

I have experienced the same issue with the installers for the versions 11.5 and 10.10 on Windows 10 x64.

However, I have found a download link for the version 11.2.1 on another website which works for me: https://www.netzwelt.de/software-download/26666-postgresql.html

0

Had the same problem, but I'm not comfortable downloading installers from unknown sources.

After quite some struggling (including run as different user, install from a session opned with a domain administrator account), the only thing that worked for me was to enable the local administrator command (net user administrator /active:yes), providing a password for it (net user administrator *) and then running the installer.

Hope this helps.

0

For me, problem was that some files inside Data folder of existing Postgres installation had cleared permissions & ownership information. I was able o fix the problem by going one level up above Data directory and re-setting the Owner of the child directories & files via standard Windows dialog. After that, re-running installer allowed icacls to set permissions & finish the installatio nsuccesfully.

0

Apparently this happens if you uninstall PostgreSQL and do not delete the "data" directory where your databases are stored. When you attempt to (re)install PostgreSQL, it fails to change permissions on that directory, because it already exists. I was able to work around this apparent bug in the installer by deleting all of C:\Program Files\PostgreSQL manually. But that might not be an option if you have data in there that you haven't backed up.

0

We had the same Problem today while upgrading from 12.1 to 12.3. Installer (EnterpriseDB) stopped with the error while icacls - call because of missing rights... We even ran it as local administrator.

After stopping the setup the pg - service was removed and rights in pg-data / base - folder were missing. We run takeown /F d:\PgData12\* /R /A and startet the setup again. Then it worked without other problems.

0

My solution was log in with the user caller admnistrator, can't be other user with permissions, must be the user administrator

0

I suspect a problem with user rights. I was able to activate the Administrator account and perform the installation.

  1. cmd (Run as Administrator)

  2. net user administrator active: yes

  3. logout old Account and login Administrator

  4. install PostgreSQL

0

For anyone still encountering this issue, try this python script before running the postgresql executable.

import os
import time
import subprocess


USER = 'something' # Change
LOCAL_USER_NAME = 'something' # Change

def apply_permissions(folder_name):
    takeown_command = f'takeown /F "C:\\Users\\{USER}\\AppData\\Local\\Temp\\{folder_name}" /R /D Y'
    icacls_command = f'icacls "C:\\Users\\{USER}\\AppData\\Local\\Temp\\{folder_name}" /grant:r "{LOCAL_USER_NAME}:(OI)(CI)F" /T /Q'

    subprocess.run(takeown_command, shell=True, check=True)
    subprocess.run(icacls_command, shell=True, check=True)

def check_for_postgresql_installer():
    temp_dir = f'C:\\Users\\{USER}\\AppData\\Local\\Temp'
    while True:
        folders = [name for name in os.listdir(temp_dir) if name.startswith("postgresql_installer_")]
        for folder_name in folders:
            apply_permissions(folder_name)
        time.sleep(0.1)

if __name__ == "__main__":
    check_for_postgresql_installer()
2
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 13 at 18:38
  • this works. thank you very much. for anyone has a ton of "postgresql_installer_***" folders like me, make sure to delete them first.
    – meowulf
    Commented Jun 3 at 3:56
-1

For me, on Postgre 16.3 installer, the problem was that the installer log, which can be found on Windows at '%temp%\install-postgresql.log' said that it tried to create a local user account with the same name as my domain account, and then it tried to set inheritance on the installer temporary folder in %temp% and icalcs could not do that, it failed. My solution was to rename the existing local account that I wasn't using to something else.

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 11 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .