Can't access site on EC2 instance via public ip

Ruby on-RailsNginxAmazon Ec2

Ruby on-Rails Problem Overview


I've been experimenting with EC2 for a couple days and have been banging my head against simply even being able to access the sample site I've hosted. The stack is Rails 3.1.3 with Thin and Nginx.

I've tried several different configurations and finally ended up running the Nginx auto install script, which does return a webpage when I do a curl http://ec2-107-20-143-179.compute-1.amazonaws.com/. However, when I point my browser there, it hangs forever before saying the page cannot be found.

I have assigned an Elastic IP address, and I've enabled HTTP access via port 80.

I don't much experience with the sysadmin side and I'm basically stumped at this point. Any advice would be greatly appreciated.

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

Did you enable the http port to all ips? That would be done by going to:

EC2 -> Security Group -> Default (or your custome one) -> Inbound

And then Create a new rule for HTTP and as a source, you should assign: 0.0.0.0/0

That should do it.

Solution 2 - Ruby on-Rails

Think the AWS UI may have been updated but based on Deleteman's answer

  • Login to EC2 Dashboard
  • Instances > Instances
  • Actions dropdown > Networking > Change security groups
  • You will probably see that you only have launch-wizard-1 allowed which for me only allowed SSH access on port 22

So as Deleteman mentions, you may need to alter your security groups...

  • Login to EC2 Dashboard
  • Network and Security > Security Groups
  • Remove any filters that may be in the search box to show all groups
  • Personally I edited the default VPC security group as this is a sandbox for me, I imagine you'll want to create a security group for your project
  • Select the security group checkbox, select actions dropdown and click "edit the inbound rules", I used the following inbound rules just to be sure it was all working

Rules

  • When you revisit Instances > Instances > Description, you should see the security groups and the rules

enter image description here

  • Once you are happy it's working I would probably replace all traffic with HTTP and HTTPS if that's all that is needed

Solution 3 - Ruby on-Rails

I was here earlier looking for a solution to a similar problem I was having. It turns out in my case that the EC2 instance also had its own firewall running in addition to the EC2 security group. The command 'system-config-firewall' let me get in to open the ports. Ports 80 (HTTP) and 3306 (MySQL) were not open by default. 22 (SSH) was open. I also had to do 'yum install system-config-firewall'.

To summarize, my solution was:

> yum install system-config-firewall
> system-config-firewall

Solution 4 - Ruby on-Rails

This answer is for the newbies who have no idea what they are doing with an ec2 instance.

I was having the same problem and tried all the Security Group fixes to no avail.

As it turns out, I needed to turn on my server from the command line.

sudo service httpd start 

Sometimes it's dark, not because a fuse blew, but because you didn't flick the switch.

Solution 5 - Ruby on-Rails

I face the same issue multiple times with the ubuntu EC2 instance and here I am adding all the methods which helped me in fixing the issue in different situations.

  1. Make sure you are accessing the "Public IPv4 DNS" or "Public IPv4 address" or "Elastic IP addresses" from the browser.

Step1 screenshots

  1. Check whether port 80 is open or not. Step2 port 80 is not open Here you can see that port 80 is not open in Inbound rules. So let's open port 80 first. For this click on the security tab and you can see the Security groups open this new tab Security group Now you have to edit inbound rules. Edit inbound rules Click at add rule Then select type HTTP and source AnyWhere and save it. enter image description here Similarly, you do HTTPS also.

  2. Check the browser URL if HTTPS is not enabled and if we try to access from browser default it might be HTTPS if so please make it HTTP and try again.

  3. Edit Network ACL. Select the Networking tab and open Subnet ID in a new window. Networking tab and subnet Id

Opened subnet Id From Subent Id open Network ACL in the new window Now edit inbound rules. Edit inbound rule 100 Rule 100 should look like this, i.e, type==

Solution 6 - Ruby on-Rails

I was also struggling with same problem had created security group as well, but did not applied to the instance. Just create new rule for http. And apply from right click instance and choose security group and assign it.

Solution 7 - Ruby on-Rails

For me, It was as simple as just changing the url from https://my-site to http://my-site on my browser. (This solution only applies to people who are still able to SSH onto the ec2 instance but cannot connect via browser)

Solution 8 - Ruby on-Rails

Octopus' answer was the correct one for me, except for a Windows machine. I needed to go to the Windows Firewall, was blocking all traffic out of the VM if it didn't match a rule. Port 80 wasn't enabled in a rule, so I merely had to add one.

Solution 9 - Ruby on-Rails

Very stupid of me as I forgot to install web server (HTTP server) because of which my ec2 instance public IP was not working. Answering this question as this can also be one of the reason which one should not miss as I did.

You can install either,

nginx:

sudo apt-get install nginx

apache2:

sudo apt-get install apache2

Solution 10 - Ruby on-Rails

I had the same issue, been racking my brain bad since I have no experience with Ubuntu or linux. The answer from Parag fixed it.

Very stupid of me as I forgot to install web server (HTTP server) because of which my ec2 instance public IP was not working. Answering this question as this can also be one of the reason which one should not miss as I did.

You can install either,

nginx:

sudo apt-get install nginx

apache2:

sudo apt-get install apache2

Solution 11 - Ruby on-Rails

I know this is a very old thread but faced this issue with many services recently. When you are running any application server like Puma or Unicorn over port example 3000, without having a Load Balancer or Proxy like Nginx frontend it. You have to follow two steps:

  1. Bind the service to 0.0.0.0/3000 and not 127.0.0.1/3000.(This will leave your service open and accessible by anybody on the internet, that is were step 2 comes into picture).
  2. In AWS security group now allow port 3000 for 0.0.0.0 if you want it be access by anybody over the internet or add VPN or your network IP to allow it only for you and you team.

Solution 12 - Ruby on-Rails

My problem was the browser.

Chrome works; Firefox DOES NOT work.

Solution 13 - Ruby on-Rails

I have encountered a quite similar situation when I tried to run my go app on EC2. If you cannot see an appropriate message or result on your browser even though you:

  • can get a response well using curl,
  • finished configuring the Security Group properly
    • open pen inbound traffic for 80, 443 for the world or for your IP address and
    • open inbound traffic for 22; and
    • open inbound traffic for a port that you use (like 8080, 4343, etc.)), and;
  • run your app to accept a connection from the outside (npm app.js, go run . etc.)

Make sure that you entered http://ec2-..., instead of https://ec2-... on your browser. You cannot connect to the server with https:// even though you open 443 port, unless you already configured ssh certificate. Entering the full address with http protocol, without omitting it, may solve the problem.

Solution 14 - Ruby on-Rails

Here are the steps that you can follow and when you check both of these, chances are that they will work for sure.

  1. Make sure that you're using http:// in the browser instead of https:// on the IP and amazon IPV4 public DNS (It comes in some form like http://ec2-some-ip-address-here.region.compute.amazonaws.com)

  2. Click on the instance id and scroll down,

go to the security tab,

click on security group it will look like this [![enter image description here][1]][1]

Click on edit inbound rules

Add this

For type- choose HTTP
Source - choose anywhere or anywhere ipv4

and click save and you're done.

Combination of these two should work fine.

Solution 15 - Ruby on-Rails

The best way is to edit your security inbound rules. Please refer to below snap.

enter image description here

Solution 16 - Ruby on-Rails

My Windows Ec2 instance was not accessible when I tried to access the public IP from the browser. After checking all the above, I had to update the Windows (Defender) Firewall setting which was blocking the incoming traffic.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionprimerView Question on Stackoverflow
Solution 1 - Ruby on-RailsDeletemanView Answer on Stackoverflow
Solution 2 - Ruby on-RailsCarltonView Answer on Stackoverflow
Solution 3 - Ruby on-RailsOctopusView Answer on Stackoverflow
Solution 4 - Ruby on-Railsuser156439View Answer on Stackoverflow
Solution 5 - Ruby on-Railsarun n aView Answer on Stackoverflow
Solution 6 - Ruby on-RailsjbmyidView Answer on Stackoverflow
Solution 7 - Ruby on-RailsSidarth NuthiView Answer on Stackoverflow
Solution 8 - Ruby on-RailsDavidView Answer on Stackoverflow
Solution 9 - Ruby on-RailsParag TyagiView Answer on Stackoverflow
Solution 10 - Ruby on-Railsuser8212792View Answer on Stackoverflow
Solution 11 - Ruby on-RailsAnanth KamathView Answer on Stackoverflow
Solution 12 - Ruby on-Railsquine9997View Answer on Stackoverflow
Solution 13 - Ruby on-RailsJames YooView Answer on Stackoverflow
Solution 14 - Ruby on-RailsKoushik DasView Answer on Stackoverflow
Solution 15 - Ruby on-RailsMaheshvirusView Answer on Stackoverflow
Solution 16 - Ruby on-Railsuser2082201View Answer on Stackoverflow