I have installed postgresql 14 on a Windows 10 machine. But, I'm getting this message:

C:\Program Files\PostgreSQL\14\bin
> pg_ctl.exe start -D "C:\postgres"
pg_ctl: directory "C:/postgres" is not a database cluster directory

The installation log file at %temp%\install-postgresql.log shows this text at the very end:

Error running C:\WINDOWS\System32\cscript //NoLogo "C:\Program Files\PostgreSQL\14/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\nephewtom\AppData\Local\Temp/postgresql_installer_80ce3934c2" "C:\Program Files\PostgreSQL\14" "C:\Program Files\PostgreSQL\14\data" 5432 "DEFAULT" 0: Program ended with an error exit code Problem running post-install step. Installation may not complete correctly The database cluster initialisation failed. Setting variable whoami from C:\WINDOWS\System32\whoami Script exit code: 0

I suspect it may be due to a permissions issue.

Checking the troubleshoot guide here, it suggests to use cscript.exe, but that failed.

  • If the installer failed to run initdb, run it manually. You may also want to run pg_ctl register with the appropriate options to create a Windows service. Mar 13 at 14:59
  • Yes, that made it, thank you very much @LaurenzAlbe !
    – nephewtom
    Mar 14 at 12:17
  • By the way, when creating a Windows service : .\pg_ctl.exe register -D c:\PostgreSQL\14\data -N postgresql -U nephewtom -P nephewtom -S auto -e postgresql pg_ctl: could not register service "postgresql": error code 1057
    – nephewtom
    Mar 14 at 12:49
  • Perhaps you don't have the required permissions, or there is already a service with that name. Mar 14 at 14:11
  • Maybe you could try a binary install - if that can suit your needs? Mar 28 at 23:36

2 Answers 2


@LaurenzAlbe comment made it.
He deserves all the credit, but I am posting the answer with commands output in case somebody has the same issue and it could help.

First, running initdb.exe :

C:\Program Files\PostgreSQL\14\bin> .\initdb.exe -D c:/PostgreSQL/14/data
The files belonging to this database system will be owned by user "nephewtom".  
This user must also own the server process.

The database cluster will be initialized with locale "English_United States.1252".  
The default database encoding has accordingly been set to "WIN1252".  
The default text search configuration will be set to "english".  

Data page checksums are disabled.

fixing permissions on existing directory c:/PostgreSQL/14/data ... ok  
creating subdirectories ... ok  
selecting dynamic shared memory implementation ... windows   
selecting default max_connections ... 100   
selecting default shared_buffers ... 128MB  
selecting default time zone ... Europe/Paris  
creating configuration files ... ok  
running bootstrap script ... ok  
performing post-bootstrap initialization ... ok  
syncing data to disk ... ok  

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    ".\pg_ctl" -D "c:\PostgreSQL\14\data\\" -l logfile start

Then starting PostgreSQL with pg_ctl.exe :

C:\Program Files\PostgreSQL\14\bin> .\pg_ctl.exe start -D c:\PostgreSQL\14\data  
waiting for server to start....  
2022-03-14 13:13:34.114 CET [1972] LOG: starting PostgreSQL 14.2, compiled by Visual C++ build 1914, 64-bit  
2022-03-14 13:13:34.126 CET [1972] LOG: listening on IPv6 address "::1", port 5432  
2022-03-14 13:13:34.126 CET [1972] LOG:  listening on IPv4 address "", port 5432  
2022-03-14 13:13:34.219 CET [26212] LOG:  database system was shut down at 2022-03-14 13:13:01 CET    
2022-03-14 13:13:34.485 CET [1972] LOG:  database system is ready to accept connections  
server started

Not sure what went wrong with your installation.
But I am pretty sure that "C:\postgres" is not the directory of your configuration files. That would be: "C:\Program Files\PostgreSQL\14\data".
(Should be the same as %postgresql_dir%\data.) So:

pg_ctl.exe start -D "C:\Program Files\PostgreSQL\14\data"
  • I had already tried that and got the same error.
    – nephewtom
    Mar 14 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.