【问题标题】:postgresql error in Cloud9 "could not connect to server: Connection refused"Cloud9 中的 postgresql 错误“无法连接到服务器:连接被拒绝”
【发布时间】:2023-03-17 08:49:01
【问题描述】:

我想在 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

宝石文件

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 中发现了类似的问题,但它们对我不起作用。 如果您能建议我如何避免此错误,我们将不胜感激。

【问题讨论】:

    标签: ruby-on-rails postgresql cloud9-ide


    【解决方案1】:

    配置postgresql.conf 文件。您必须将 listen_addresses 更新为 all 并确保通过删除 # 标记取消注释该行。所以你的listen_addresses 应该是这样的listen_addresses = '*'

    【讨论】:

    • 感谢您的回答,@chalitha lawanga。我已经在postgresql.conf 中编辑了listen_addresses = '*'
    猜你喜欢
    • 2017-04-28
    • 2013-05-19
    • 1970-01-01
    • 2020-08-19
    • 2011-12-29
    • 1970-01-01
    • 2014-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多