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
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
您也可以强制停止然后强制启动服务器
sudo service postgresql stop --force
sudo service postgresql start --force
I had this error due to not properly configured connection to database, and exactly because of syntax errors in setting up environment variables ie
MY_APP_DB= $MY_APP_DB_NAME
which is wrong, instead of MY_APP_DB=$MY_APP_DB_NAME
sudo systemctl start postgresql
First, you need to make sure the socket file
is located in /var/run/postgresql/.s.PGSQL.5432
. To check that
$ cat /var/run/postgresql/.s.PGSQL.5432
if result shows something, then the problem is anything else. But, if file is not there you need to check /tmp
dir (specially for OSX Homebrew
users)
$ cd /tmp
$ l
total 16
drwxrwxrwt 7 root wheel 224B Mar 11 08:03 .
drwxr-xr-x 6 root wheel 192B Jan 23 18:35 ..
-rw-r--r-- 1 root wheel 65B Nov 7 22:59 .BBE72B41371180178E084EEAF106AED4F350939DB95D3516864A1CC62E7AE82F
srwxrwxrwx 1 shiva wheel 0B Mar 11 08:03 .s.PGSQL.5432
-rw------- 1 shiva wheel 57B Mar 11 08:03 .s.PGSQL.5432.lock
drwx------ 3 shiva wheel 96B Mar 10 17:11 com.apple.launchd.C1tUB2MvF8
drwxr-xr-x 2 root wheel 64B Mar 10 17:10 powerlog
Now, there are two ways you can solve the error
You can change the application configuration to see for sockets at /tmp/.s.PGSQL.5432
# config/database.yml
default: &default
adapter: postgresql
pool: 5
# port:
timeout: 5000
encoding: utf8
# min_messages: warning
socket: /tmp/.s.PGSQL.5432
You can create symlinks to the expected location
$ sudo mkdir /var/pgsql_socket
$ sudo ln /tmp/.s.PGSQL.5432 /var/pgsql_socket/
Then the error should go.
Hope this helps.
Try this that works for me.
sudo systemctl start postgresql
then
sudo systemctl start postgresql
What you have to do to solve the problem of s.PGSQL.5432:
First change the unix_socket_directories postgresql.conf path / tmp / by another route
and then updates the postgres and postgres load becomes, if you want you can put the path again, and with it and recharge the postgres normally.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.