2

Can anybody advise why my Postgres log still occassionally generate line saying:

"FATAL: database ABCD does not exist"

When that ABCD literally does not exist anywhere and also not listed in pg_database?

What is it cross checking against to generate that log message?

I would like to remove this faulty fatal log message. Thanks.

2 Answers 2

2

Something is trying to connect to your cluster, expecting ABCD to be available.

My bet is someone saved a misconfigured connection profile in a database client like DBeaver, DataGrip, pgAdmin and it's just checking it from time to time, or that somewhere in your codebase someone left an example line without modifying the dbname that ends up in a connection string. There could also be a test case or rarely used code path doing something else and simply ignoring the failed connection attempt.

demo at db<>fiddle

select pg_rotate_logfile();
create extension dblink;
select dblink_connect('','dbname=ABCD');
ERROR:  could not establish connection
DETAIL:  connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: 
FATAL:  database "ABCD" does not exist
create function readlog()returns text return
 pg_read_file('log/'||(array(select (pg_ls_logdir()).name order by 1 desc))[1]);
select readlog();
readlog
2026-02-28 10:00:08.099 GMT [791] FATAL: database "ABCD" does not exist
2026-02-28 10:00:08.101 GMT [790] ERROR: could not establish connection
2026-02-28 10:00:08.101 GMT [790] DETAIL: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: database "ABCD" does not exist
2026-02-28 10:00:08.101 GMT [790] STATEMENT: select dblink_connect('','dbname=ABCD');

Ask other users of the database about dead connection profiles and grep your repo for this ABCD.

1

A FATAL error in PostgreSQL is an error that terminates a database connection.

That is your clue: such an error message is logged when somebody tries to connect to a non-existing database. After the successful authentication, PostgreSQL cannot connect the session to the database, raises the error you observe and terminates the connection.

Usually, that is a harmless error that you can ignore. If it happens too often, search for automated tools that are trying to connect to that non-existing database.