124

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?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Cat
  • 7,042
  • 8
  • 34
  • 36
  • Possible duplicate of [Opening port 80 EC2 Amazon web services](http://stackoverflow.com/questions/5004159/opening-port-80-ec2-amazon-web-services) – bain Jan 20 '16 at 01:00
  • Possible duplicate of [EC2: How to add port 8080 in security group?](http://stackoverflow.com/questions/26338301/ec2-how-to-add-port-8080-in-security-group) – Amit G Apr 21 '16 at 07:24
  • 67
    right, I should have anticipated someone will ask the same question a year later – Cat Apr 21 '16 at 09:49
  • 2
    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](https://stackoverflow.com/a/55474171/1768141). – Vinayak Apr 02 '19 at 12:11

4 Answers4

159

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

Sikandar Khan
  • 129
  • 2
  • 16
cyraxjoe
  • 5,661
  • 3
  • 28
  • 42
  • 1
    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? – Noitidart Aug 30 '18 at 20:00
  • 1
    @Noitidart Save is what he means. But I am sure you figured that out by now :) – mattdevio Oct 26 '18 at 07:31
  • Thanks @mattdevio - it seems to work but not from certain locations, I think I might have screwed something up. – Noitidart Oct 26 '18 at 11:39
  • Also, check the solution provided by @SurajKj if you're dealing with Windows EC2 instance. That solution along with this one worked for me. – Utkarsh Oct 10 '19 at 15:51
  • 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. – KKOrange Dec 12 '19 at 01:39
35

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.

dmohr
  • 2,699
  • 1
  • 22
  • 22
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

SurajKj
  • 706
  • 7
  • 13
  • 1
    I was stuck with the issue for long; this worked like a charm. Thanks a lot! This solution needs more traction. – Utkarsh Oct 10 '19 at 15:50
3

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