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

2.2k views Asked by At

I tried running a postgres server to viewing my databases with TablePlus after not doing so for a while.

Running the server:

brew services start postgresql
Warning: Formula postgresql was renamed to postgresql@14.
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/eliott/Library/LaunchAgents/[email protected]` exited with 5.
➜  ~ brew services restart postgresql
Warning: Formula postgresql was renamed to postgresql@14.
Stopping `postgresql@14`... (might take a while)
==> Successfully stopped `postgresql@14` (label: homebrew.mxcl.postgresql@14)
==> Successfully started `postgresql@14` (label: homebrew.mxcl.postgresql@14)

When I ran psql it returned this error:

psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory Is the server running locally and accepting connections on that socket?

… and something similar in TablePlus.

The version was 14.7 at this point so decided to install 15 with homebrew brew install postgresql@15 (though the version is now only 14.8) but now the error has changed to:

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

in TablePlus:

connection to server at “127.0.0.1”, port 5432 failed: FATAL: database “eliott” does not exist

When I run psql -l, the following is returned:

List of databases
   Name    | Owner  | Encoding | Collate | Ctype | Access privileges 
-----------+--------+----------+---------+-------+-------------------
 postgres  | eliott | UTF8     | C       | C     | 
 template0 | eliott | UTF8     | C       | C     | =c/eliott        +
           |        |          |         |       | eliott=CTc/eliott
 template1 | eliott | UTF8     | C       | C     | =c/eliott        +
           |        |          |         |       | eliott=CTc/eliott
(3 rows)

EDIT: the CLI works now but what I didn't realise before from running psql -l is that all the databases I used to have are gone now. I'm guessing I may have deleted them by accident(?) or is there the possibility that postgres/tableplus is looking for the wrong path?

0

There are 0 answers