skip to Main Content
  • I created a new Ubuntu T2 Micro instance on EC2, created a new Elastic IP and selected EIP used in: VPC, associated the address to my new EC2 Ubuntu instance.

I now have a Private IP and a Public/Elastic IP. No Public DNS. My security group has SSH port 22 and HTTP port 80 and HTTPS 443 open. I use Terraform to create server

user_data = <<-EOF
#!/bin/bash
sudo apt update -y
sudo apt install apache2 -y
sudo systemctl start apache2
sudo bash -c "echo your very first web server > /var/www/html/index.html"
EOF

I can connect to the instance just fine through SSH using AWS console, but when I try to browse to the Public IP through the browser it says connection refused. I can’t ping it either.

I use systemctl status to check the server, it’s saying

├─apache2.service 
             │ ├─2108 /usr/sbin/apache2 -k start
             │ ├─2111 /usr/sbin/apache2 -k start
             │ └─2112 /usr/sbin/apache2 -k start

I can ping google.com form the Server.

I’m out of ideas.
Get website connected from public IP

2

Answers


  1. Chosen as BEST ANSWER

    This issue is fixed automatically when I tried to get in the web by public IP the second day. I am not sure if this issue is due to AWS cloud infra need time to consume new public IP? Like noticing routing table or forwarding table, but luckily it passed.

    I think AWS supporter should troubleshoot this kind of issue, I believe not only me met it.


  2. Some things to be aware of:

    • Using SSH from the AWS Console (EC2 Instance Connect) isn’t a valid test, as that doesn’t require your instance to have a public IP.
    • Just having a public IP assigned to your instance doesn’t automatically make it available on the Internet.
    • If your security group only allows TCP ports 22, 80 and 443, then you would not be able to ping the server.

    Some things to try:

    • Verify that you have an Internet Gateway and that the route table for the subnet your EC2 instance is in has a route to the Internet.
    • Check the NACL on the subnet your EC2 instance is in and make sure it is not blocking the traffic.
    • Make sure there is nothing preventing you from accessing the server, such as a corporate firewall or proxy.
    • Try connecting to Apache from the command line on the instance to verify Apache is really serving pages: curl -v http://localhost or even curl -v http://PUBLIC_IP_OF_INSTANCE
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search