PostgreSQL error 'Could not connect to server: No such file or directory'

前端 未结 22 1877
梦谈多话
梦谈多话 2020-11-29 17:20

Like some others I am getting this error when I run rake db:migrate in my project or even try most database tasks for my Ruby on Rails 3.2 applications.

相关标签:
22条回答
  • 2020-11-29 18:12

    It's very simple. Only add host in your database.yaml file.

    0 讨论(0)
  • 2020-11-29 18:13

    This worked for me for the error you mentioned. Do one of these:

    1. Possibly change your default port specified in the postgres.conf file, if you have used something other than the default port 5432 while installing.

    2. Change the port number in postgresql.conf and restart the DB server.

    3. Instead of psql type the full command:

      psql -p 5432 -h localhost   
      
      • server name and the port no
    0 讨论(0)
  • 2020-11-29 18:14

    "Postgres.app" is a better fix if you are on OS X


    Here is the fix:

    1. Stop the database
    2. cd /var
    3. sudo rm -r pgsql_socket
    4. sudo ln -s /tmp pgsql_socket
    5. chown _postgres:_postgres pgsql_socket
    6. Restart PostgreSQL (not your computer)

    More information is available at "postgresql 9.0.3. on Lion Dev Preview 1".

    0 讨论(0)
  • 2020-11-29 18:16

    I fixed this by upgrading postgres.

    brew update
    brew upgrade
    

    Then I had to also upgrade the databases to be compatible with the new major version, because I upgraded from 10 to 11.

    brew postgresql-upgrade-database
    

    (source https://github.com/facebook/react-native/issues/18760#issuecomment-410533581)

    0 讨论(0)
提交回复
热议问题