Home > database >  psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: database &
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: database &

Time:01-30

I a rails app running on my local environment using postgresql. This morning I spun up a new one and after install the pg gem, etc. I am running into the following error when trying to run

psql
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  database "jackcollins" does not exist

What's strange is the db name "jackcollins" is from my other rails app.

I ran

pgrep -l postgres

and the output was

20902 postgres
20919 postgres
20920 postgres
20921 postgres
20922 postgres
20923 postgres
20924 postgres

I'm unsure how to proceed so that these apps can both run their own postgres instance.

CodePudding user response:

Regarding the error, you are trying to connect to jackcollins, please can you test trying to connect using the database flag?:

psql -d your_database_name

CodePudding user response:

In the absence of -d <database_name> psql will use the OS user name as the database name. As in many things it better to be explicit rather then implicit, especially when working on a new instance. In addition use -h <host_name>, -p <port_number> and -U <user_name>. Then you know who you are connecting as, as well as how. It is spelled out here psql and since psql is a libpq program in more detail here Key words.

  •  Tags:  
  • Related