Psql: could not connect to server

Keywords: PostgreSQL - Linux - Technical issue - Other
I am working on django with postgresql, When i try to run command psql it gives below error:

$ sudo su postgres
$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?

How can i solve this issue? Previously it was working, I created one database also.

I also tried localhost=’*’ in config file.

I solved it.

My mistake was that first i was using command sudo su postgres instead psql -U postgres


We are glad that you were able to fix the issue. We are marking the previous answer as “Solution” and this topic as “Solved”.
If you have any other questions, please do not hesitate to let us know. Feel free to create a new topic referencing to this one if necessary.

Best regards,
Carlos R. Hernández