Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

psql on Windows warns that the console code page differs from the Windows code page

ErrorWARNING: Console code page (437) differs from Windows code page (1252)

Short answer

psql is a console application, and the Windows console uses a different encoding than the rest of the system. psql warns at startup when it finds a problematic console code page. It only matters for 8-bit characters. Set the console code page with chcp, choose the Lucida Console font, and check the client encoding.

  • Applies to PostgreSQL 16, PostgreSQL 17, Windows 11, cmd.exe
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the console which code page it is using, and then ask psql which client encoding it settled on.

    chcp
    psql -U postgres -c "\encoding"
  2. 2Match what you see, then jump to its fix

    1. 1The warning appears at every psql start, and accented or non-English text shows as wrong charactersThe console code page is not the one psql expectsFix
    2. 2The warning is gone, but non-ASCII characters still show as boxes or wrong shapesThe console font cannot show the charactersFix
    3. 3Characters typed in psql come back different, or an encoding conversion error is reportedThe client encoding does not match what you typedFix

What does the error look like?

  • WARNING: Console code page (437) differs from Windows code page (1252)
  • psql prints a warning at startup about a problematic console code page

Cause 1 of 3

The console code page is not the one psql expects

1Check

Windows console windows use a different encoding than the rest of the system. The numbers in the warning are the console code page and the system's ANSI code page. chcp prints the console one.

chcp

2Fix

Switch the console to the Windows code page before starting psql. 1252 is only an example; use the second number from your own warning.

cmd.exe /c chcp 1252

3Verify

Start psql again and look for the warning.

psql -U postgres

Confirmed by postgresql.org

Did this fix it?

Cause 2 of 3

The console font cannot show the characters

1Check

The raster font does not work with the ANSI code page, so check which font the console window uses.

chcp

2Fix

Set the console font to Lucida Console, then start psql again.

# no command: right-click the console title bar, open Properties, choose Font, select Lucida Console

3Verify

Run a query that returns a non-ASCII value.

psql -U postgres -c "SELECT 'x' AS value"

Confirmed by postgresql.org

Did this fix it?

Cause 3 of 3

The client encoding does not match what you typed

1Check

The client encoding tells the server how to read what psql sends. \encoding shows the current setting, and PGCLIENTENCODING, if defined in the environment, selects it at connection time.

psql -U postgres -c "\encoding"
echo %PGCLIENTENCODING%

2Fix

Set the client encoding to match the console code page you chose. WIN1252 is the PostgreSQL name for code page 1252; a WIN1252 client is converted to and from a UTF8 server.

\encoding WIN1252
-- or, before starting psql
set PGCLIENTENCODING=WIN1252
-- or in SQL
SET client_encoding TO 'WIN1252';

3Verify

The session reports the value you set.

SHOW client_encoding;

Confirmed by postgresql.org

Did this fix it?

How do I stop it coming back?

  • Run chcp in a startup script or shortcut before psql, so the code page is the same every time.
  • Use the same code page for a script file, the console and the client encoding.
  • Use a graphical client for data with many non-English characters.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.