简体   繁体   中英

postgresql could not connect error.

Here is my error.

PG::Error - could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (fe80::1) and accepting
    TCP/IP connections on port 5432?

I installed postgresql using homebrew into /usr/local/bin/psql In order to get it to recognize this version I had to add this to my bash file.

export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

When I cd into my rails app and run command

rails s

it starts up with the following

=> Booting Thin
=> Rails 4.0.0.beta1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

Then when I try to view the app on http://0.0.0.0:3000 I get the above error anyone might know why this might happening.

As the message says, the most likely cause of this error is that you are not actually running the postgres server. Normally you'd boot this up with */etc/init.d/pg_ctl,* but since you installed this through brew, just run the following command in a Terminal window

postgres

And the server should boot up. If you don't have this set to automatically start upon launch you'll need to run that command every time after you restart your machine.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM