postgresql 连接超时_PostgreSQL:无法连接到服务器:连接超时

I've been trying to make the switch to PostgreSQL (from SQLite). I'm developing in the environment of Cloud9. However, on db migration I get the error message:

PG::ConnectionBad: could not connect to server: Connection timed out.

Is the server running on host "mydomain.c9.io" (IP address) and

accepting TCP/IP connections on port 5432?

I've been reading all sorts of previously asked questions on this topic but without success. Does anyone see what might be going wrong?

Do I perhaps need to makes change to the pg_hba.conf file? The current version of the file:

# Database administrative login by Unix domain socket

local all postgres peer

# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only

local all all peer

# IPv4 local connections:

host all all xxx.0.0.1/32 md5

# IPv6 local connections:

host all all ::1/128 md5

# Allow replication connections from localhost, by a user with the

# replication privilege.

#local replication postgres peer

#host replication postgres xxx.0.0.1/32 md5

#host replication postgres ::1/128 md5

database.yml:

default: &default

adapter: postgresql

encoding: unicode

host: 'mydomain.c9.io'

pool: 5

username: my_username

password: my_password

development:

<<:>

database: app_development

test:

<<:>

database: app_test

production:

<<:>

database: app_production

I have gem 'pg' in the Gemfile and have run bundle install. Also, I have created the database app_development (used sudo service postgresql start, sudo sudo -u postgres psql and then create database "app_development";) as well as the database app_test. And lastly, I created a new user in psql with CREATE USER my_username SUPERUSER PASSWORD 'my_password';.

Using sudo nano /etc/postgresql/9.3/main/postgresql.conf I also set listen_addresses = '*' but that made no difference.

What might be causing the error message?

解决方案

Are you sure that your cloud 9's has postgres port(5432) open for access? I assume the cloud 9 host is not listening on port 5432. You can check out this link for detais

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值