How to Open Port in Amazon EC2 instance

By default Amazon EC2 only allow port 22 (SSH) on Linux servers and port 3389 (RDP) on Windows Instances. All other ports are closed for security reasons. Depending on your use case, you may need to open ports on the security group to allow connection to applications you run on the EC2 instance.

Log in to the Amazon EC2 console.

In the navigation pane, click instances. This will list all available Amazon EC2 instances. Find the instance ID of the EC2 instance where you need to open the port.

AWS EC2 instance ID

Click on the Instance ID to find more details about the Amazon EC2 server.

AWS EC2 Security Group

On the AWS EC2 Instance details page, click on the “Security” tab. Below you will see “security groups”. A security group is like a firewall, you can allow/disallow incoming and outgoing ports here. Click on the Security Group ID to go to the security group page.

Amazon EC2 security group details

Click on the “Edit inbound rules” button. You can add or remove rules on the “Edit inbound rules” page.

Open Port in AWS

To Ope a port, click on “Add rule” button.

how to add inbound rules in aws ec2

To open a port, you need to add a rule for the port by clicking “Add rule” button.

You will get a new entry, where you need to select your rule.

Type = This is a drop-down select box with the default value “Custom TCP”. You can find many predefined rules for common services like HTTP, HTTPS, MySQL, etc.. You can use Custom TCP or Custom UDP, then enter the port number you need to open.

Port range = You can enter the port number to open on this text box.

Source = This is IP add where you are allowed to connect. To allow all connections, use 0.0.0.0/0

Description – optional = you can enter a note so you know what this port is used for.

Once you added this, click on the “Save rule” button to save the rule. It will configure the security group to allow the port you added.

aws ec2 open port 8080

This screenshot shows the rules needed to Open Port 8080 on the AWS security group for Anyone.

Back to Amazon EC2

Comments

2 responses to “How to Open Port in Amazon EC2 instance”

  1. sterin Avatar
    sterin

    how to change the port to a custom port,
    I need to change the port number of 80 to 2333.is that possible? or not,
    if it is possible how can i do it

    1. ServerOk Avatar
      ServerOk

      You can change port 80 to whatever port you want. To do this, first open the port in the security group, next you need to change the port in the application, if it’s apache web server, update the apache config, and change “Listen 80” to “Listen 2333”. On Ubuntu, you can change the Apache web server port by editing file /etc/apache2/ports.conf

Leave a Reply

Your email address will not be published. Required fields are marked *