Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

could not connect to server: "/var/run/postgresql/.s.PGSQL.5432"?

I have a simple web page in Ruby On Rails with postgresql database, but when I run sever I have this error, I don't Know that I do. I use postgresql because heroku need that the aplication is in postgresql.

I work in ubuntu 13.10

The error is:

PG::ConnectionBad 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 need help

thanks

like image 807
mayrues Avatar asked Mar 31 '14 13:03

mayrues


People also ask

Can't connect to PostgreSQL server?

“Could not connect to server: Connection refused” To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql. If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections.

Is Postgres running on port 5432?

The PostgreSQL database service is available on localhost and the default PostgreSQL port is 5432 . A default user ( hosting-db ) and database ( postgres ) exist so you can quickly test your connection and perform management tasks.

How can I tell if Postgres is running on 5432?

If you are trying to connect to a Postgres instance on the same host as your terminal, you can run lsof -p :5432 which will show which, if any, processes are listening on that port. The postgres process should be connected there. You can also look at the listen_address and port value in your postgresql.

How do I open port 5432 on Windows?

Open Windows Firewall Port As an alternative you can go to Control Panel -> Systems and Security -> Windows Firewall -> Allow a program or feature through Windows Firewall -> Advanced Settings -> New Rule: Rule Type: Port. TCP or UDP: TCP. Specific local ports: 5432.


2 Answers

Just create a softlink like this,this works for me

$ sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432

for more info

like image 194
ramamoorthy_villi Avatar answered Sep 25 '22 21:09

ramamoorthy_villi


Also you are able to force stop and then force start the server

sudo service postgresql stop --force

sudo service postgresql start --force

like image 21
Sergey Bezugliy Avatar answered Sep 26 '22 21:09

Sergey Bezugliy