无法从EC2(elastic-beanstalk)连接到RDS PostgreSQL 9.3数据库。环境是使用Elastic Beanstalk v3 CLI和PostgreSQL 9.3.5,Puma(Ruby 2.1),Rails 4.1.6创建的。 yum通过.ebextensions / postgres.config成功安装了postgresql93-devel:
packages:
yum:
postgresql93-devel: []
SECRET_KEY_BASE已通过控制台添加到Environment表中。
在eb deploy期间在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验证到ec2框。
配置/ 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'] %>
有什么想法吗?
答案 0 :(得分:1)
您似乎在database.yml中错误地写了主机名而不是主机