How to open a web server port on EC2 instance [closed]
Asked Answered
M

4

128

I'm running a CherryPy web server at 0.0.0.0:8787 on an EC2 instance.

I can connect to the web server via local wget on the EC2 machine, but I can't reach the instance from my own remote machine (I connect to EC2 via ssh).

Do I need to open up port 8787 to access the web server remotely? If so, how can this be done? Also, can I use the public IP of the EC2 instance for this?

Melchior answered 18/6, 2013 at 5:44 Comment(3)
Possible duplicate of Opening port 80 EC2 Amazon web servicesMonovalent
Possible duplicate of EC2: How to add port 8080 in security group?Omnidirectional
If you're opening a non-standard port (e.g. 8787) on the EC2 instance and trying to access the host from a corporate network but aren't able to do so, maybe your organization is blocking outbound access to that port. In that case, check out this answer.Liberalism
H
164

Follow the steps that are described on this answer just instead of using the drop down, type the port (8787) in "port range" an then "Add rule".

Go to the "Network & Security" -> Security Group settings in the left hand navigation

enter image description here Find the Security Group that your instance is apart of Click on Inbound Rules enter image description here Use the drop down and add HTTP (port 80) enter image description here Click Apply and enjoy

Hexose answered 19/6, 2013 at 3:44 Comment(5)
I don't see "Apply" I only see "Save". When I click "Save" it is not opening my port 3000, is there an "Apply" button somewhere?Tektite
@Tektite Save is what he means. But I am sure you figured that out by now :)Lechery
Thanks @mattdevio - it seems to work but not from certain locations, I think I might have screwed something up.Tektite
Also, check the solution provided by @SurajKj if you're dealing with Windows EC2 instance. That solution along with this one worked for me.Infirmity
It wasn't immediately clear to me from the linked instructions, but you should select "Custom TCP". Otherwise you won't be able to change the port.Ileac
J
37

You need to open TCP port 8787 in the ec2 Security Group. Also need to open the same port on the EC2 instance's firewall.

Jonas answered 21/6, 2013 at 6:7 Comment(7)
Does it use iptables?Sitwell
how, is there a link or tutorial to do so?Rocker
How do you open the port on the EC2 instance's firewall?Culpa
@MahshidZeinaly parallels.com/blogs/ras/…Isotron
This is for windows then. I do not think for ubuntu you need to do anything! Just open the security group for UbuntuCulpa
How to open on the instnances firewall?Tektite
everyone wondering about the instance's firewall, it depends on the OS running on the instance. this isn't an AWS configuration, it's the same thing you'd configure if you had to OS installed on your local machine (vs. on AWS). e.g. for Ubuntu, this is usually ufw, but I think the Ubuntu 20.04 AMI has ufw disabled by defaultDollie
I
16

You need to configure the security group as stated by cyraxjoe. Along with that you also need to open System port. Steps to open port in windows :-

  1. On the Start menu, click Run, type WF.msc, and then click OK.
  2. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.
  3. In the Rule Type dialog box, select Port, and then click Next.
  4. In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number , such as 8787 for the default instance. Click Next.
  5. In the Action dialog box, select Allow the connection, and then click Next.
  6. In the Profile dialog box, select any profiles that describe the computer connection environment when you want to connect , and then click Next.
  7. In the Name dialog box, type a name and description for this rule, and then click Finish.

Ref:- Microsoft Docs for port Opening

Interferometer answered 30/7, 2018 at 13:10 Comment(1)
I was stuck with the issue for long; this worked like a charm. Thanks a lot! This solution needs more traction.Infirmity
Z
4

You just need to run command

sudo iptables -A INPUT -p tcp --dport <port_number> -j ACCEPT

You will be allow to access port in AWS Ubuntu

Ziegler answered 13/5, 2022 at 7:42 Comment(1)
Can you explain how this helps?Diapositive

© 2022 - 2024 — McMap. All rights reserved.