Connection refused (PGError) (postgresql and rails)

前端 未结 6 1066
栀梦
栀梦 2020-12-06 01:37

I keep getting this error when i try to run my localhost using \"$rails s\":

(Mac OSX 10.8.3) (ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]) (R

6条回答
  •  萌比男神i
    2020-12-06 01:54

    The error message is instrumental:

    could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5433?
    

    port

    You may be trying to connect to the wrong port.
    Standard port is 5432. Check how (and whether at all) you started your postgres server:

    postgres@db:~$ ps -auxww | grep ^postgres
    ... 
    postgres  1274  0.0  0.3 1437240 57308 ?       S    May27   5:01 /usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf
    

    The manual has related information here.

    In my example, settings from /etc/postgresql/9.1/main/postgresql.conf got used, which says (among many other settings):

    port = 5432
    

    Or run:

    netstat -nlp | grep postgres
    

    Or just look here (at least in Debian or Ubuntu):

    ls -lA /var/run/postgresql/
    

    PostgreSQL picks the next free port if you create a new database cluster. Since you installed repeatedly, you may have confused port numbers.

    listen_addresses

    Or you just forgot to allow TCP/IP connections. Related answers:

    • Run batch file with psql command without password
    • What's the difference between "local" and "localhost" connection types in pg_hba.conf?
    • no pg_hba.conf entry for host

提交回复
热议问题