How to open ports for aws EC2 instance


When we crreate new aws ec2 instances, they only have port 22 opened by default due to default security policy.

If we want to use this instance as a webserver for our websites or for nodejs apps or node servers running behind react app, etc., we need to open relevant ports on the aws ec2 instance.

Open port access for AWS EC2 instance

To open inbound ports access, goto aws ec2 instance list and click on the id of your instance to select it. It will open the instance summary page. On that page, look for Security tab and click it.

In the security tab you will see the Security details, Inbound rules and Outbound rules.

Click on the name of your Security group under Security groups.

Note that these rules and settings are related to aws ec2 architecture and not your virtual server instance itself. So you need to open the same ports inside your virtual machine instance too once you’ve modified them here. You can do that following steps here: ufw firewall to view & open ports.

Now on the security group detail page, we can see the detail of inbound and outbound rules for this security group.

In this view, click on Edit inbound rules and it will take you to the next page where you can edit, remove or add inbound rules. There we will add rules for ports that we need, such as 80 (for regular http traffic), 443 (for ssh / https traffic) or any other ports that you need.

Check this modified inbound rules list (discussed under image):

In this list, we had only first entry of type SSH initially. Then we did this process to add more:

  1. Click on Add rule
  2. Select the type from the drop down for type, you can select predefined one or you can also just choose Custom TCP (as in last item) and add port 80 or any other yourself.
  3. Make sure that you add ip in Source to be 0.0.0.0/0 so that it accepts incoming connection to this port from any ip address.
  4. Once done, click save rules.

Now your aws ec2 instance is ready to accept incoming requests on these ports. Make sure that you open these ports in your linux / operating system on virtual machine too as explained above.


Leave a Reply

Your email address will not be published.