It appears that your package manager failed to create the database named $user for you. The reason that
psql -d template1
works for you is that template1 is a database created by postgres itself, and is present on all installations. You are apparently able to log in to template1, so you must have some rights assigned to you by the database. Try this at a shell prompt:
createdb
and then see if you can log in again with
psql -h localhost
This will simply create a database for your login user, which I think is what you are looking for. If createdb fails, then you don't have enough rights to make your own database, and you will have to figure out how to fix the homebrew package.
Answer from Kirk Roybal on Stack OverflowIt appears that your package manager failed to create the database named $user for you. The reason that
psql -d template1
works for you is that template1 is a database created by postgres itself, and is present on all installations. You are apparently able to log in to template1, so you must have some rights assigned to you by the database. Try this at a shell prompt:
createdb
and then see if you can log in again with
psql -h localhost
This will simply create a database for your login user, which I think is what you are looking for. If createdb fails, then you don't have enough rights to make your own database, and you will have to figure out how to fix the homebrew package.
From the terminal, just Run the command on your command prompt window. (Not inside psql).
createdb <user>
And then try to run postgres again.
Database current username does not exist issue
database "postgres" does not exist
The Postgresql DB does not exist
FATAL: database "postgres" does not exist
I have existing multiple *_development and *_test databases on postgres 12. Postgres by default creates a postgres user upon installation. I am always logged in as the current linux user on my system.
Why doesnt psql let me login into psql without specifying a specific database by throwing the error message psql: error: could not connect to server: FATAL: database "<current username>" does not exist?
Instead, the commands psql -d my_application_development and sudo -u postgres psql work even though the latter does not say which database
PS what is template0 and template1? was it a mistake in name
In Database Navigator > Right click on PostgreSQL > Edit Connection
In Connection settings > general tab, enter your host (e.g. localhost), database (e.g. postgres) and leave User blank. Check Show all databases.
Right click on PostgreSQL and refresh. You should get a green checkmark in the PostgreSQL icon.
That's how I fixed mine, hopefully it'll work for you too.
Like Joseph, I had to leave the localhost but I had to clear all the fields, tick Show Databases:

Then refreshing on the databases I got prompted for the Username and Password (must have been an old version in cache):

This works, and you'll see there's potentially more than one schema:

Hi guys, I've been googling around on how to solve the problem with resolving my issue into getting back into postgresql 11...
I dropped the postgres database in my software then it led to me not able to reconnect to the server.
I've tried doing some code on the command line with adding a database and entering password but not working or recovering the access with psql -u postgres.
None haven't worked. IDK where to go because I'ved seen like several sources and no luck. I wanna resume coding on postgresql.
Thanks...
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.
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.
Hi,
I'm running the alpine PostgreSQL image in docker using the following docker-compose file below. After building and starting, the container gives the following fatal error message: "FATAL: database "admin" does not exist". After some googling it looks like postgresql needs a database to exist same to the user name that I declared in the docker-compose. Anyone an idea how to solve the error?
version: '3.8' x-systeminfo: &systeminfo # Database POSTGRES_ADDRESS: database POSTGRES_DB: dev POSTGRES_USER: admin POSTGRES_PASSWORD: **************** POSTGRES_PORT: 5432 services: database: build: ./Database restart: always ports: - 5432:5432 environment: *systeminfo volumes: - postgresqldata:/var/lib/postgresql/data healthcheck: test: pg_isready -U $$POSTGRES_USER interval: 10s timeout: 5s retries: 20 volumes: postgresqldata:
The docker file inside ./Database looks like this:
FROM postgres:alpine COPY . /docker-entrypoint-initdb.d/