无法从EC2(弹性豆茎)连接到RDS PostgreSQL 9.3数据库。环境是使用 Elastic Beanstalk v3 CLI 和 PostgreSQL 9.3.5、Puma (Ruby 2.1)、Rails 4.1.6 创建的。PostgreSQL93-Devel由Yum通过.ebExtensions/postgres.config成功安装:
packages:
yum:
postgresql93-devel: []
SECRET_KEY_BASE已通过控制台添加到环境表中。
在 eb 部署期间在 rake db:migrate 上收到以下错误:
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
RDS_HOSTNAME、RDS_DATABSE、RDS_USER_NAME、RDS_PASSWORD:所有这些都在 Rails 控制台中通过 SSH to EC2 box 进行了验证。
config/database.yml:
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
production:
<<: *default
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
hostname: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
有什么想法吗?
看来您在 database.yml 中错误地编写了主机名而不是主机