5

While deploying an application with Rails 3.2.17, we are getting following error.

eb-commandprocessor.log

+ su -s /bin/bash -c 'leader_only bundle exec rake db:migrate' webapp
rake aborted!
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"?
/var/app/ondeck/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace) (ElasticBeanstalk::ActivityFatalError)
    at /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:189:in `rescue in exec'
    ...
caused by: command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh

Here is our database.yml configuration

 production:
  adapter: postgresql
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>

Surprisingly we are able to start rails console and we also verified that all above environment variables return correct value.

And also able to connect via psql with following command psql -h RDS_HOSTNAME -d RDS_DB_NAME -U RDS_USERNAME

3
  • I have the same problem here but with Rails 4 Commented Jun 23, 2015 at 20:09
  • any luck figuring this out? Commented Jul 17, 2015 at 2:06
  • Same problem here. Also working when doing it manually. Working on it... Commented Sep 25, 2015 at 17:50

1 Answer 1

1

On my side the issue was coming from the fact that I deleted my .elasticbeanstalk/optionsettings and so RACK_ENV was not defined, AWS set it by default to production which led my application to have the wrong database hostname.

I debugged that by adding echo statement in /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh to display RACK_ENV and noticed it was empty.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.