我想在 Cloud9 中为我的rails应用设置postgresql。
当我尝试bundle exec rake db:create
时出现以下错误。
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?
...
的database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: <%= ENV['USERNAME'] %>
password: <%= ENV['PASSWORD'] %>
host: localhost
development:
<<: *default
database: app_development
test:
<<: *default
database: app_test
production:
<<: *default
database: app_production
的Gemfile
gem 'pg', '~> 0.18.2'
/etc/postgresql/9.3/main/的的pg_hba.conf
# Database administrative login by Unix domain socket
local localhost ubuntu md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all ubuntu md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
虽然我在stackoverflow中发现了类似的问题,但它们并不适合我。 如果您能告诉我如何避免此错误,将不胜感激。
答案 0 :(得分:0)
配置postgresql.conf
文件。您必须将listen_addresses
更新为all,并确保通过删除#mark来取消注释该行。因此,listen_addresses
应该如下listen_addresses = '*'