1

I'm stuck deploying my (second) Rails 5.2 app to AWS using Elastic Beanstalk. The code is deployed fine, but the PostgreSQL 9.4.18 database is causing problems.

EB correctly created the RDS instance. The relevant part of my database.yml is as follows:

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

These ENV variables are all populated in the EB web interface.

I can connect to the RDS server using pgAdmin III, having added the Inbound rule to allow my IP address access.

But here's the problem: I can't create the database after SSHing into the EC2.

When I type

rails db:seed

or

rails db:reset

I get this error:

Traceback (most recent call last):
        10: from bin/rails:4:in `<main>'
         9: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
         8: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
         7: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
         6: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
         5: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
         4: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
         3: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
         2: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
         1: from /opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/compile_cache/iseq.rb:37:in `load_iseq'
/opt/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/compile_cache/iseq.rb:37:in `fetch': Permission denied - bs_fetch:atomic_write_cache_file:open (Errno::EACCES)

And when I try

sudo env PATH=$PATH RAILS_ENV=production bundle exec rake db:seed

I get this error

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"?
/opt/rubies/ruby-2.5.1/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:abort_if_pending_migrations
(See full trace by running task with --trace)

Pretty opaque to me as I thankfully don't need to do this often.

Since my earlier app works (although on an earlier version of Ruby), I have compared RDS, Configuration and all other AWS settings I can think of. What am I missing?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.