error with postgresql datababse : Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?

后端 未结 8 913
执笔经年
执笔经年 2021-02-05 17:09

When I run the rake db:migrate or run the rails s command, I get the same error:

Error : could not connect to server: 
No such file or         


        
8条回答
  •  我寻月下人不归
    2021-02-05 17:45

    I had the same Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”? error when typing psql into the postgres user in Ubuntu 14.04. I could not find an existing working solution.

    The short answer for me was: my install made a var/pgsql_socket directory but no configuration files knew about it.

    1) Find the postgres.conf file (it was in etc/postgresql/9.6/main for me)
    2) change to listen_addresses = '*'
    3) add another unix socket directory
    unix_socket_directories = '/var/run/postgresql, /var/pgsql_socket' # comma-separated list of directories
    4) at this point, sudo service postgresql start attempted to start but did not have authority to create the lock file.
    * The PostgreSQL server failed to start. Please check the log output: 2016-10-05 17:14:55 CEST [28472-1] FATAL: could not create lock file "/var/pgsql_socket/.s.PGSQL.5432.lock": Permission denied 2016-10-05 17:14:55 CEST [28472-2] LOG: database system is shut down
    5) Change permissions ( found from Mark Berry's comment here )
    $ sudo chown root.postgres /var/pgsql_socket
    $ sudo chmod g+wx /var/pgsql_socket
    6) sudo service postgresql start
    sudo -i -u postgres
    psql

    That finally worked for me

提交回复
热议问题