AWS EC2 Instance Unable to Connect from Browser but MySQL Access via SSH Works - Mysql2::Error::ConnectionError in Rails Production Server

58 views Asked by At

I'm currently facing an issue with my AWS EC2 instance, and I need some guidance to resolve it.

I'm a newbie and am trying to upgrade the Ubuntu version from 18.04 LTS to 20.04. After the version upgrade not able to connect the mysql through the browser.

I have an EC2 instance with a public IP address, say, 18.205.116.208. When I try to access my instance via a web browser like https://18.205.116.208, it doesn't connect. However, I can successfully connect to the MySQL database on the EC2 instance via SSH using the following command: mysql -u root -p --host=18.205.116.208 --port=3306

My Rails production server is running on the same EC2 instance, and when I check the production logs using: tail -f log/production.log I see the following error message: Mysql2::Error::ConnectionError (Can't connect to MySQL server on '127.0.0.1' (111))

It seems like the Rails application is trying to connect to MySQL on the local host (127.0.0.1) and failing.

I'd like to know how to resolve this issue and why the EC2 instance is not accessible through a web browser. Any help or suggestions are appreciated.

Here are the details of aws ec2 instance security groups Please do let me know if need any other information.

0

There are 0 answers