Search code examples
amazon-web-servicesnetwork-programmingamazon-ec2windows-serverwindows-server-2016

AWS EC2 Windows Server 2016 expose port 80


What I'm trying to do is access my webserver on my EC2 from the outside.

Here's what I've done so far:

  • I've opened all Incoming Traffic to anywhere both for IPv4 and IPv6 in the EC2's Security group
  • Disabled the firewall from the Control Panel in the EC2 for both public and private
  • Started my webserver on port 80

From outside the ec2:

  • I can ping the EC2 succesfully
  • If I run telnet <my ec2 ip> 80 I get telnet: Unable to connect to remote host: Connection refused
  • If I run nmap <my ec2 ip> port 80 is not listed

From inside the ec2:

  • I was able to connect from localhost:80 in EC2's browser
  • If I ran netstat -aon it shows it is listening on port 80

Solution

  • Make sure that your web server is bound to the external network interface.

    Using 0.0.0.0 will ensure that connections can be made from any interface. On the other hand, using 127.0.0.1 (localhost) would have behavior like what you describe, where you can connect to the web server locally, you can reach the host externally (e.g. via ping) but cannot connect to the web server externally.