2016-02-01 74 views
0

我有一台虚拟机,我用它来测试数据库。用户名和密码是postgres,IP是192.168.1.255。 在我的Rails应用我有一个test.json文件有以下几点:虚拟机上的PostgreSQL数据库不能正常工作

{ 
    "db": "postgres://postgres:[email protected]: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? 

想法?

回答

0

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

listen_addresses 

,并设置为

listen_addresses='*' 

购买的方式,你也应该检查你的pg_hba.conf,以接受通过IP连接。

+0

我该如何检查该条目?我的pg_hba.conf有我的计算机IP作为可信 – WhomWhomWhom

+0

检查文档在这里: – otaviofcs

+0

http://www.postgresql.org/docs/9.1/static/auth-pg-hba-conf.html。类似于:host postgres all 192.168.12.10/32 md5 – otaviofcs