DEV Community

Erik Guzman
Erik Guzman

Posted on

TIL: How to Run Rails Console in Elastic Beanstalk App

I have a Ruby on Rails application deployed to AWS Elastic Beanstalk. Up to this point, I haven't needed to directly run Rails console for my application in production since I am using various admin dashboard plugins to track most things. If not, I can also use AWS Cloudwatch.
Today, I needed to access the Rails console to run a command for some database management stuff. I ran the standard Elastic Beanstalk CLI command to ssh:

eb shh
Enter fullscreen mode Exit fullscreen mode

But after that, I had an issue trying to run bundle exec rails c in /var/app current. It just kept giving me errors. After some searching for some help, I came across an excellent StackOverflow article the helped me out.

I have set up a RoR environement on AWS' elastic beanstalk. I am able to ssh into my EC2 instance My home directory is /home/ec2-user, which is effectively empty. If I move up a directory, there is also a /home/webapp directory that i do not have access to.

It turns out I needed to switch my user to get the job done.

sudo su
bundle exec rails c
Enter fullscreen mode Exit fullscreen mode

Andddddd done.

Top comments (1)

Collapse
 
pritambios profile image
Pritam Pramanik

Its not working for me. Unable to connect to DB