Search code examples
phpamazon-web-servicesamazon-ec2portpublic

Unable to access running PHP server on 8080 port of ec2 instance


I deployed a code on an AWS ec2 instance. enter image description here

I also added security groups to allow public access to the instance enter image description here

I made sure that the firewall is disabled enter image description here

The IP tables also seem to be in order enter image description here

I'm still unable to access the website via public IP & browser enter image description here

Using the following command to ping the server's public IP address -

Using the command - Test-NetConnection -computername <public IP>

enter image description here It seems like its working. However, when I add the desired port number to the command

Test-NetConnection -computername <public IP> -port 8080

It seems like the test is failing enter image description here

What am I missing?


Solution

  • Servers do not only listen on ports, but also on addresses. You have entered localhost:8080 i.e. 127.0.0.1:8080 which means the server will accept connections at address 127.0.0.1, port 8080. If you would connect to this address it would work. Except this address isn't reachable over the network.

    If you would tell it to listen on the server's (private) IP address (172.something), or 0.0.0.0 which means "any address", then it would work. Typically, 0.0.0.0 is used for listening addresses to allow connections from the network, or 127.0.0.1 is used to only allow connections from the same computer. It's rare to use other listening addresses, but it can be done if your computer has two networks and you only want the server to work from one of them.