【问题标题】:PostgreSQL DB on virtual machine not working虚拟机上的 PostgreSQL 数据库不工作
【发布时间】:2016-05-10 14:30:38
【问题描述】:

我有一个虚拟机,我用它来存放我的测试数据库。用户名和密码是 postgres,ip 是 192.168.1.255。 在我的 Rails 应用程序中,我有一个 test.json 文件,其中包含以下内容:

{
  "db": "postgres://postgres:postgres@192.168.1.255:5432/geoforce_test?search_path=gfv2,public",
  "log_level": 1,
  "db_log": "log/v2-test.db.log"
}

但是,当我尝试运行测试 (rspec spec) 时,我收到以下错误:

PG::ConnectionBad: could not connect to server: Permission denied (Sequel::DatabaseConnectionError)
    Is the server running on host "192.168.1.255" and accepting
    TCP/IP connections on port 5432?

想法?

【问题讨论】:

    标签: ruby-on-rails postgresql rspec


    【解决方案1】:

    您的 PostgreSQL conf 设置为侦听您所有的服务器 IP?默认情况下,postgresql.conf 只监听 localhost。检查条目:

    listen_addresses
    

    并设置为

    listen_addresses='*'
    

    顺便说一句,你应该检查你的 pg_hba.conf 以便接受通过你的 IP 的连接。

    【讨论】:

    猜你喜欢
    • 2014-07-04
    • 2013-04-10
    • 1970-01-01
    • 2014-04-12
    • 1970-01-01
    • 2018-02-18
    • 2017-07-05
    相关资源
    最近更新 更多