4

I'm trying to connect my Rails app to an EC2 instance that contains a PG database. I've already checked with Navicat that I can connect to the database given the EC2 details. The issue is that when run locally the Rails app can't be viewed; it throws the error "database configuration does not specify adapter". A similar issue is thrown when I try a database migration. I haven't even tried to push this up to my Rails EC2 since it isn't working locally.

My database.yml file looks like this:

production:
 adapter: postgresql
 encoding: unicode
 database: postgres
 host: ec2-54-197-115-117.compute-1.amazonaws.com
 pool: 10
 port: 5432 (have both included and removed this line)
 username: a database username for security
 password: the password associated with that user

My gem files include the gem pg.

For the database name I just wrote what it had in Navicat, but perhaps there's an official name associated with it I should be using; if so, how would I find it? The host I got from the EC2 details. And the username and password were the ones I set with the postgres database via unix.

Thanks in advance for any insight!

Edit:

Fixed!

0

1 Answer 1

2

Fixed! I had forgotten to create an actual DB after setting up the PG; I changed the name in my database.yml file to reflect the new db name. Also, I needed to set on my Rails app environment directly (I thought Apache did this automatically w/Passenger) with "export RAILS_ENV=production". I thought it was still broken when I restarted my server and nothing had changed, but I just had to restart the console. Hope this helps someone else out too!

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

1 Comment

Thanks for submitting the solution - it helped me big-time! To get mine to work, I had to add the name of the db to the hostname to make it work; in other words, in the RDS management console, the "Endpoint" was "staging.blabla.eu-west-1.amazonaws.com:5432". I removed the :5432 part, but left in "staging.", which is the name of my database. Just FWIW!

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.