I can ssh to my EC2 instance and start a web server on it:

$ ssh -i ~/AWSKeyPair1.pem ec2-user@
Last login: Mon Jul 20 18:50:58 2015 from 72-21-196-64.amazon.com

       __|  __|_  )
       _|  (     /   Amazon Linux AMI

$ echo 'Hello world' > index.html
$ sudo service iptables status
iptables: Firewall is not running.
$ python -m SimpleHTTPServer 8888
Serving HTTP on port 8888 ...

And curl it from the instance

$ curl
Hello world

But curls from my laptop fail

$ curl
curl: (7) Failed to connect to port 8888: Connection refused

Why might this be? My Security Groups are set to allow all traffic from anywhere (, and my Route Table routes all traffic to the appropriate gateway.

(Previous question)

  • $ sudo netstat -a -n | grep 8888 from another terminal while the web server is running. What does it show? Jul 20, 2015 at 22:02
  • Incidentally, this works from my mobile phone. Possibly an issue with your laptop or the network your laptop is on? Jul 20, 2015 at 22:04

2 Answers 2


Make sure you have your AWS security groups are setup to allow access at port 8888 using a custom TCP rule.

verify your local network firewall allows outbound connections to port 8888.


In my case the python server running on the aws instance was only listening (and serving) to localhost or / interface. Thus it will ignore connections from the outside. For me starting the python server on worked. From the output you printed it looks like, it already does - but might be worth a shot or help others

  • dude you are a life saver i totally forgot to remove localhost! Thanks Dec 24, 2021 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.