Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open port 80 on AWS EC2

I want to open port 80 to allow HTTP connections on my EC2 server. But when I'm entering "telnet xx.xx.xx.xx 80" on a terminal the following is displayed

"Trying xx.xx.xx.xx..." 
telnet: Unable to connect to remote host: Connection timed out

In AWS I've opened port 80 by defining an Inbound Rule on the Security group (only one security group is defined for this EC2 server)

enter image description here

enter image description here

I'm using the Public IPv4 address to make a telnet connection

enter image description here

like image 665
user2023141 Avatar asked Dec 04 '25 09:12

user2023141


1 Answers

I noticed you have a fresh install -- fresh installs do not have software listening over HTTP by default.

If there is no application listening on a port, incoming packets to that port will simply be rejected by the computer's operating system. Ports can be "closed" through the use of a firewall, which you have disabled, therefore the ports are open just unresponsive which makes them appear closed.

If the port is enabled in the firewall in the terminal using

sudo apt-get install ufw
sudo ufw allow ssh
sudo ufw allow https
sudo ufw allow http
sudo reboot

and enabled in the AWS console as a rule, the port is open and just not responsive so it's seen as closed. By installing either nginx or something that binds to port 80, external requests to that port will be connected successfully, and the port will therefore be recognized as open. The reason ssh is recognized as open is because 1. it has firewall transparency, and 2. it is always listening (unlike port 80!). Before installing nginx even though ports are allowed through the firewall: enter image description here

sudo apt-get install nginx
sudo ufw allow 'Nginx HTTP'
sudo systemctl status nginx

(more nginx info)

After: enter image description here

Simple port tester tool here

like image 193
Keegan Murphy Avatar answered Dec 07 '25 00:12

Keegan Murphy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!