38. psql: error: connection to server on socket

What a morning!

I spent 2 hours trying to get my PostgreSQL working!

psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory

I did everything from uninstall, install, restart, remove everything and start all over again! It just wouldn’t work. I tried almost all the solutions given on forums and blogs. Nil.

Finally, I got it to work with these commands I got from a coding tutor:

And boom! It worked.

What do the above 3 lines mean?

Let’s break down each line:

ls /opt/homebrew/var/postgresql@14/postmaster.pid:

  • This line uses the ls command to list the contents of a specific file or directory.
  • /opt/homebrew/var/postgresql@14/postmaster.pid is the path to a file named postmaster.pid.
  • The @14 part in the path indicates a version number or identifier, possibly version 14 of PostgreSQL installed via Homebrew.
  • So, this command is listing the contents of the file postmaster.pid in the specified directory.

rm /opt/homebrew/var/postgresql@14/postmaster.pid:

  • This line uses the rm command to remove (delete) a file.
  • /opt/homebrew/var/postgresql@14/postmaster.pid is again the path to the file postmaster.pid.
  • This command is attempting to delete the file postmaster.pid.


  • This command is typically used to launch the PostgreSQL interactive terminal.
  • When executed without any arguments, it opens up the PostgreSQL interactive terminal where you can execute SQL queries and interact with the PostgreSQL database management system.

In summary:

  • The first line lists the contents of a specific file.
  • The second line attempts to delete that file.
  • The third line launches the PostgreSQL interactive terminal.

Hope this helped you too!

Leave a Reply

Your email address will not be published. Required fields are marked *