PostgreSQL:无法连接到服务器:连接超时 [英] PostgreSQL: could not connect to server: Connection timed out

查看:6882
本文介绍了PostgreSQL:无法连接到服务器:连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试切换到PostgreSQL(从SQLite)。我在Cloud9的环境中开发。但是,在数据库迁移时,我收到错误消息

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:无法连接到服务器: 连接超时。
服务器在主机mydomain.c9.io(IP地址)上运行,
在端口5432上接受TCP / IP连接?

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?

我可能需要更改 pg_hba.conf 文件吗?文件的当前版本:

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:
  <<: *default
  database: app_development
test:
  <<: *default
  database: app_test
production:
  <<: *default
  database: app_production

我在 Gemfile 中有 gem'pg',并且运行 bundle install 。此外,我有创建数据库 app_development(使用 sudo服务postgresql开始 sudo sudo -u postgres psql 然后创建数据库app_development; )以及数据库app_test。最后,我用 CREATE USER my_username SUPERUSER PASSWORD'my_password'; 中创建了一个新用户。

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';.

使用 sudo nano /etc/postgresql/9.3/main/postgresql.conf 我还设置了 listen_addresses ='*'但没有什么区别。

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?

推荐答案

确保您的云9的postgres端口(5432)打开访问?我假设云9主机没有在端口5432上侦听。您可以检查这个链接为detais

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

http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html a>

这篇关于PostgreSQL:无法连接到服务器:连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆