Skip to content

MrSteelSC/postgresql-windows-locale-cluster-fix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Why PostgreSQL Fails on Windows with Certain Locales

Database Cluster Initialization Failed (Root Cause & Fix)

TL;DR

On Windows, PostgreSQL installation may fail during database cluster initialization when using certain system locales (not only Turkish).

Root cause: locale / collation incompatibility during initdb.

Solution:
Always install PostgreSQL using the en_US locale, regardless of your system language.


Error Message

During installation, PostgreSQL may fail with an error similar to:The database cluster initialization failed.

The installer may then roll back and remove installed binaries automatically.


Root Cause (Technical Explanation)

PostgreSQL relies on system locale and collation settings during initdb.

On Windows, some locales (such as tr_TR, az_AZ, lt_LT, and others) can cause collation or ICU-related issues. These issues prevent PostgreSQL from correctly initializing the default database cluster.

This is not a PostgreSQL bug specific to Turkish — it affects multiple locales.

On Windows, PostgreSQL relies on ICU and Windows locale APIs, which behave differently than POSIX locales used on Linux systems.


Solution (Recommended)

Clean Installation Steps

  1. Uninstall PostgreSQL from Apps & Features

    • Ignore uninstall errors if any occur
  2. Manually delete the remaining directory:C:\Program Files\PostgreSQL

  3. Run the PostgreSQL installer as Administrator

  4. During installation, when prompted for Default Locale:

❌ Do NOT select your system language
❌ Do NOT select tr_TR, az_AZ, lt_LT, etc.

✅ Select English (United States)

or

  1. Complete the installation

PostgreSQL should now initialize the database cluster successfully.


Example: Correct Locale Selection

PostgreSQL Locale Selection


Manual Recovery (Advanced)

If PostgreSQL is already installed but the cluster failed, you can manually initialize it:

initdb -E UTF8 --locale=en_US -U postgres -D C:\pgsql\data
pg_ctl start -D C:\pgsql\data

> Run Command Prompt or PowerShell **as Administrator**



























Key Takeaway

On Windows systems, PostgreSQL should always be installed using the en_US locale,
regardless of the system language or regional settings.

This avoids collation issues and prevents database cluster initialization failures.

Keywords (for search engines)

postgresql database cluster initialization failed

postgresql windows locale error

initdb failed windows

postgresql tr_TR locale bug

postgresql ICU collation issue

postgresql windows installation failed
postgresql initdb locale windows




## License

MIT License









About

Fix PostgreSQL database cluster initialization failure on Windows caused by locale and ICU collation issues (tr_TR, az_AZ, lt_LT). Root cause and permanent solution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors