简体   繁体   English

Cloud9中的postgresql错误“无法连接到服务器:连接被拒绝”

[英]postgresql error in Cloud9 “could not connect to server: Connection refused”

I'd like to setup postgresql for my rails app in Cloud9 . 我想在Cloud9中为我的rails应用程序设置postgresql。

The following error appeared when I tried to bundle exec rake db:create . 当我尝试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 /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

Although I found similar questions in stackoverflow, they don't work for me. 尽管我在stackoverflow中发现了类似的问题,但它们对我不起作用。 It would be appreciated if you could advise me on how to avoid this error. 如果您能建议我如何避免此错误,将不胜感激。

Configure the postgresql.conf file. 配置postgresql.conf文件。 You have to update the listen_addresses to all and make sure to uncomment that line by removing the # mark. 您必须将listen_addresses更新为全部,并确保通过删除#标记取消注释该行。 So your listen_addresses should look like this listen_addresses = '*' 因此,您的listen_addresses应该看起来像这个listen_addresses = '*'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PG ::错误:无法连接到服务器:连接被拒绝 - PG::Error: could not connect to server: Connection refused 无法连接到服务器:连接被拒绝 - could not connect to server: Connection refused Heroku Rails部署失败,并显示错误“无法连接到服务器:连接被拒绝” - Heroku Rails deploy fails with error “could not connect to server: Connection refused” 如何在Docker上将Rails与Postgresql连接? 正在获取:无法连接到服务器:连接被拒绝 - How to connect rails with postgresql on docker? Getting: could not connect to server: Connection refused PG::ConnectionBad - 无法连接到服务器:连接被拒绝 - PG::ConnectionBad - could not connect to server: Connection refused PG :: ConnectionBad:无法连接到服务器:连接被拒绝 - PG::ConnectionBad: could not connect to server: Connection refused Rails db:create using PostgreSQL return PG::ConnectionBad: 无法连接到服务器:连接被拒绝 - Rails db:create using PostgreSQL return PG::ConnectionBad: could not connect to server: Connection refused 耙子中止,无法连接做postgresql:连接被拒绝 - Rake aborted, Could not connect do postgresql: connection refused Rails-在服务器上创建postgres数据库会引发错误“无法连接到服务器:连接被拒绝” - Rails - Creating postgres database on server throws error “could not connect to server: Connection refused” PostgreSQL:无法连接到服务器:连接超时 - PostgreSQL: could not connect to server: Connection timed out
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM