Win 10 Postgresql 11 database cluster initialisation failed

I've just struggled with this for several hours, so I'm posting this for anyone else who winds up here.

Initially, all I could find were two bug reports on the pgsql-bugs mailing list:

BUG #15856: The program "postgres" was found by "initdb" but was not the same version as initdb.

BUG #15970: Db initialization error - initdb.exe and postgres not same version

The specific symptoms are:

The program "postgres" was found by ".../initdb.exe" but was not the same version as initdb.

and although the versions match, you get this:

C:\Program Files\PostgreSQL\11\bin>postgres -V
WARNING:  01000: could not determine encoding for locale
"<some encoding>.utf8": codeset is "CPutf8"

If these are your symptoms, the issue is that you have your region/language settings set to use UTF-8 (beta setting). This causes problems with lots of programs, and PostgreSQL is one of them. Disable this and re-install and you should be fine.

UTF8 Region Settings screenshot


Follow these steps to avoid this error

  1. Uninstall PostgreSQL
  2. Delete if you have postgres user
  3. Right click on My Computer / This PC and click on Manage goto Local Users and Groups then Users New User enter Username as postgres and Password (whatever you want) and click on Create button.
  4. Now right click on postgres user and click on properties click on Member of tab and then on Add button here click on Advanced and a new dialog box open for Groups click on Find Now and select Administrators click OK button.
  5. Now open Command Prompt / cmd
  6. here type runas /user:postgres cmd.exe and hit enter
  7. cd path to downloaded Postgresql folder enter
  8. postgresql-x.x.x-x-windows.exe enter (here x reflect release, major and minor versions).
  9. Now repeat step 4 and remove group Administrators and add Power Users