I can't curl one of my installed software using the external EC2 ip address but if I curl using localhost:5000 (or, it works fine. Any insights will be appreciated.

I've installed these 3 items:

  • Elasticsearch, port 9200        => I can curl using internal and external IP
  • Jenkins, port 8080                 => I can curl using internal and external IP
  • Python Flask app, port 5000 => I CAN'T curl using external IP. Internal IP works fine

Using the external IP address, I can curl the first two items but not the python flask application.

Here's the error below. I replaced the real ip address with "external_ip":

$ curl -v external_ip:5000
* Rebuilt URL to: external_ip:5000/
* Hostname was NOT found in DNS cache
*   Trying external_ip...
* connect to external_ip port 5000 failed: Connection refused
* Failed to connect to external_ip port 5000: Connection refused
* Closing connection 0
curl: (7) Failed to connect to external_ip port 5000: Connection refused

Here's the curl version:

$ curl --version
curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3

Here's the OS version:

$ cat /etc/lsb-release

netstat shows all ports are being listened to but the port in question is linked to How can I get this to be mapped to the external ip address?

$ sudo netstat -an | grep -E "5000|9200|8080"
tcp        0      0*               LISTEN
tcp6       0      0 :::9200                 :::*                    LISTEN
tcp6       0      0 :::8080                 :::*                    LISTEN

By the way, I ran into the same results using Vagrant.

Any ideas?

closed as off-topic by user9517, Dennis Kaarsemaker, MichelZ, kasperd, Ward Sep 15 '14 at 1:08

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Connection refused generally means nothing is listening on the relevand IP:port pair, we already have loads of Q&A about this – user9517 Sep 13 '14 at 16:26

Flask apps by default only listen on the local interface, if you want your app to be available on external addresses, start it as app.run(host='')

  • Thanks. I tried something with your idea but I'm completely new to the Python world so I'll talk to the developer about it and come back with the results. – sftoparis Sep 13 '14 at 16:55
  • Dennis, after digging around some more, I found the right place to make your changes. Thanks! I'm very happy to enter the world of Python. – sftoparis Sep 13 '14 at 17:04
  • 3
    Can you say what that place was? – Walrus the Cat Oct 18 '14 at 23:10
  • 1
    @sftoparis sudo tell us where the right place was – superhero Nov 18 '15 at 11:21

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