Home:ALL Converter>How to solve psql error: could not connect to server?

How to solve psql error: could not connect to server?

Ask Time:2020-01-21T20:15:24         Author:Julien Mertz

Json Formatter

I'm trying to install GeoDjango for my website. To do that, I first need to create a PostgreSQL database. Following this tutorial, I'm trying to connect to PostgreSQL by using sudo su - postgres and then psql. The problem is that I get this error : psql: error: could not connect to server: 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"?

I made some researchs and found this post explaining how to solve the problem. However, when I run sudo service postgresql start I have to type the password for postgres but I don't know what it is, I never created a password for postgres. I've made researchs about that and I can't find a solution because all solutions need to first connect to psql in order to alter the existing user. But I need first to find the password in order to solve the problem of connection to psql.

What am I supposed to do ?

Thanks in advance !

PS : I'm using windows 10 with the Ubuntu terminal.

PS2 : I've found some topics saying it's easier to install PostgreSQL and PostGIS using Docker. However, there are lots of compatibility problems with Docker due to the fact I'm using windows 10. Do you think I should use Docker ?

Author:Julien Mertz,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59840950/how-to-solve-psql-error-could-not-connect-to-server
yy