psql on Windows warns that the console code page differs from the Windows code page
WARNING: 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.
Fix it fast
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"2Match what you see, then jump to its fix
- 1
The 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
The warning is gone, but non-ASCII characters still show as boxes or wrong shapesThe console font cannot show the charactersFix - 3
Characters typed in psql come back different, or an encoding conversion error is reportedThe client encoding does not match what you typedFix
- 1
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.
chcp2Fix
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 12523Verify
Start psql again and look for the warning.
psql -U postgresConfirmed by postgresql.org
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.
chcp2Fix
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 Console3Verify
Run a query that returns a non-ASCII value.
psql -U postgres -c "SELECT 'x' AS value"Confirmed by postgresql.org
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
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
Databases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
DBeaver cannot download the PostgreSQL driver from Maven
The PostgreSQL driver files are missing and the download does not complete
DBeaver downloads the PostgreSQL JDBC driver from a Maven repository the first time you connect.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
Django save fails on PostgreSQL: null value in a column violates a not-null constraint
django.db.utils.IntegrityError: null value in column "price" of relation "shop_product" violates not-null constraint
A model field is NOT NULL in the database unless it has null=True.
3 causes, each with a fixDatabases
Django migration on PostgreSQL stops with 'pending trigger events'
django.db.utils.OperationalError: cannot ALTER TABLE "mytable" because it has pending trigger events
PostgreSQL runs a Django migration in one transaction.
2 causes, each with a fixDatabases
Django cannot connect to PostgreSQL: connection refused on port 5432, locally or in Docker
Is the server running on that host and accepting TCP/IP connections?
Connection refused means nothing accepted the connection at the host and port Django used.
4 causes, each with a fix