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 Overflow
🌐
Reddit
reddit.com › r/docker › postgresql in docker: database "admin" does not exist error
r/docker on Reddit: PostgreSQL in docker: database "admin" does not exist error
January 14, 2024 -

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/
🌐
GitHub
github.com › tiredofit › docker-db-backup › issues › 291
No Backups Created - errors in PostgreSQL logs · Issue #291 · tiredofit/docker-db-backup
November 21, 2023 - If I run backup-now in the container terminal, I get this: psql: error: connection to server at "192.168.75.10", port 5432 failed: FATAL: database "admin" does not exist Are the keys in the template wrong for postgreSQL?
Author   tiredofit
Discussions

Report errors "FATAL: role "XXX" does not exist" when POSTGRES_USER is customized.
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: role "admin" does not exist More on github.com
🌐 github.com
5
October 25, 2023
postgresql - psql: fatal database does not exist error - Database Administrators Stack Exchange
I have a linux user account, postgresql role, and associated database, all called foo. from the linux user foo, I ran the command dropdb foo Now when I try to run psql from the linux user foo, I... More on dba.stackexchange.com
🌐 dba.stackexchange.com
cloudsql postgres user cannot connect
After creating a postgres instance with a user. and connecting via the google documentation per https://cloud.google.com/sdk/gcloud/reference/sql/connect I get the below error. it sees admin as a d... More on github.com
🌐 github.com
2
February 1, 2019
FATAL: database "..." does not exist
SEVERE: Connection error: org.postgresql.util.PSQLException: FATAL: database "..." does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477) at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2603) at ... More on discourse.metabase.com
🌐 discourse.metabase.com
0
0
April 4, 2018
🌐
GitHub
github.com › docker-library › postgres › issues › 1138
Report errors "FATAL: role "XXX" does not exist" when POSTGRES_USER is customized. · Issue #1138 · docker-library/postgres
October 25, 2023 - psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: role "admin" does not exist
Author   docker-library
🌐
Broadcom Community
community.broadcom.com › education › question › psql-fatal-database-gpadmin-does-not-exist
psql: FATAL: database "gpadmin" does not exist | VMware Tanzu Greenplum
September 15, 2024 - Unable to perform psql command. I ran the command gpstart, I got following messageHave lock file /tmp/.s.PGSQL.5432 and a process running on port 5432.gpstart
🌐
PostgreSQL
postgresql.org › message-id › 1155685965.28246.6.camel@dell.home.lan
PostgreSQL: Re: psql: FATAL: Database "postgres" does not exist in
August 15, 2006 - So if you run it as user "postgres", and a db with that name does not exist (yet), it will complain. You should first create a database using "createdb somename" and then connect with "psql somename". Note you can get a list of available databases with psql -l. > > Any help is appreciated. > > Thanks > > John Vandervliet · Bye, Chris. ... psql: FATAL: Database "postgres" does not exist in the system catalog.
🌐
Dbdocs
dbdocs.net › postgresql › fatal-database-does-not-exist
FATAL: database does not exist in PostgreSQL
August 28, 2024 - Learn how to resolve the 'FATAL: database does not exist' error in PostgreSQL. Discover the causes, solutions, and examples to fix this common database issue.
Find elsewhere
🌐
GitHub
github.com › teslamate-org › teslamate › discussions › 2131
FATAL: database "teslamate" does not exist · teslamate-org/teslamate · Discussion #2131
Hey guys - think I figured it out and hope this helps, as it worked for me. Not sure why we were all routed to this discussions/issues black hole, but here it is: In the docker-compose.yml file, add "- DATABASE_POOL_SIZE=10" under the list of teslamate environment variables.
Author   teslamate-org
🌐
GitHub
github.com › hashicorp › terraform › issues › 20202
cloudsql postgres user cannot connect · Issue #20202 · hashicorp/terraform
February 1, 2019 - Connecting to database with SQL user [admin].Password for user admin: psql: FATAL: database "admin" does not exist csmith190@cloudshell:~ (xxxx)$ gcloud sql connect sql-sandbox-a2bc0f33 --user=admin
Author   hashicorp
🌐
Metabase
discourse.metabase.com › get help
FATAL: database "..." does not exist - Get Help - Metabase Discussion
April 4, 2018 - I got below error logs from my metabase container SEVERE: Connection error: org.postgresql.util.PSQLException: FATAL: database "..." does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(Quer…
🌐
IBM
ibm.com › support › pages › nzhostbackup-error-database-admin-does-not-exist
nzhostbackup error, Database "ADMIN" does not exist
$ If you run the command as root user (via sudo) without the environment variable defined correctly, you'll receive the same error: $ sudo /nz/kit/bin/nzhostbackup file2 Password: (######) Starting host backup. System state is 'pausedNow'. Checkpointing host catalog ... Archiving system catalog ... nzsql: FATAL 1: Database "ADMIN" does not exist.
🌐
DigitalOcean
docs.digitalocean.com › how do i fix the "database does not exist" error when connecting to postgresql?
How do I fix the "Database Does Not Exist" error when connecting to PostgreSQL? | DigitalOcean Documentation
December 20, 2021 - A Database Does Not Exist error ... "defaultdb" does not exist · If you are getting this error, first verify that you are using the correct hostname to connect by following How to Connect to PostgreSQL Database Cluste...
🌐
PostgreSQL
postgresql.org › message-id › 33039DBDED22BE47B9F45999ED0D7A0409926B@XMBTX143.northgrum.com
PostgreSQL: Fatal: Database does not exist
February 27, 2009 - Hi, I get the error "FATAL: Database "xxx" does not exist" when trying to connect to the database using JDBC. The superuser "postgres" owns my database and tables. However, it seems I can only connect to the database when the username matches the name of the database I am connecting to.
🌐
Medium
wajeeh-ahsan.medium.com › psql-error-fatal-database-xxx-does-not-exist-5d4724613c67
psql: error: FATAL: database “XXX” does not exist - Wajeeh Ahsan - Medium
January 7, 2021 - psql: error: FATAL: database “XXX” does not exist This is because, postgres isn’t having a role with this name. To get rid of this error, you need to create this role. Make sure the name of the …
🌐
GitHub
github.com › docker-library › postgres › issues › 403
FATAL: database does not exist [docker compose] · Issue #403 · docker-library/postgres
January 26, 2018 - psql: FATAL: database "test" does not exist · Everything works fine witout compose · docker run -it -e POSTGRES_USER=test -e POSTGRES_PASSWORD=qwerty -e POSTGRES_DATABSE=mydb postgres docker exec -it <CONTAINER_ID> /bin/bash psql -U test · results: root@cb18469bc86e:/# psql -U test psql (10.1) Type "help" for help.
Author   docker-library
🌐
SitNGo Wizard
forums.holdemmanager.com › showthread.php
Transferred computers - Postgres DB Does Not Exist error
I"m now on travel, and trying to restore that db and getting the following when I try to restore via PG ADmin: C:\Program Files\PostgreSQL\9.0\bin\pg_restore.exe --host localhost --port 5432 --username postgres --dbname \"P1\" --verbose "C:\Documents and Settings\Steve Sundberg\Desktop\P1 DB 122410.backup" pg_restore: connecting to database for restore pg_restore: [archiver (db)] connection to database ""P1"" failed: FATAL: database ""P1"" does not exist pg_restore: *** aborted because of error Process returned exit code 1.
🌐
Reddit
reddit.com › r/aws › "database does not exist" when connecting to postgres aws rds db
r/aws on Reddit: "database does not exist" when connecting to postgres AWS RDS db
December 17, 2018 -

I keep getting the error:

psycopg2.OperationalError: FATAL:  database "aa1ktrt0k1bv3s6" does not exist

whenever attempting to connect to the db. I think I have all the security groups correctly set up, but it thinks the database doesn't exist. I've triple checked the name and hostname (I disabled the security group and it timesout instead of giving this error).

I'm not sure what I'm doing wrong. I'm sure the db name is correct, but it doesn't connect.

    db_name = "aa1ktrt0k1bv3s6"
    user_name = ''
    db_pword = ''
    db_host = 'aa1ktrt0k1bv3s6.ctsxwr4cvxhd.us-east-1.rds.amazonaws.com'
    db_port = '5432'

    query = """
            
            """
    params = (self.project_id,)

    conn = psycopg2.connect(database=db_name, user=user_name, password=db_pword, host=db_host, port=db_port)
    cur = conn.cursor()

...etc....

Am I missing some security setting somewhere? I can't find anyone else on the internet with this issue.

Edit: In case it matters, the DB was set up by elastic beanstalk in a dev environment.

🌐
Reddit
reddit.com › r/sql › fatal: database "postgres" does not exist
r/SQL on Reddit: FATAL: database "postgres" does not exist
April 8, 2019 -

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...