nerdcortex
nerdcortex

Reputation: 147

AWS Connection Refused on Port 8080

I have an EC2 instance in which I am running a Flask server on port 8080.

* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)

I can run curl and get the response from my EC2 instance.

$ curl -X GET '0.0.0.0:8080/fbeac'

However, I cannot use the public IP/DNS to get the response and running

$ curl -X GET '3.135.62.118:8080/fbeac'

results in curl: (7) Failed to connect to 3.135.62.118 port 8080: Connection refused. I get the same error when I try to curl using my local machine.

My application is listening on port 8080, which I checked by running netstat.

$ netstat -an | grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN

Moreover, I have ensured the Security Groups are set up correctly. I have experimented with just custom TCP port 8080, all TCP ports, and (currently) all traffic. I have also opened up HTTP/HTTPS ports on the side just in case, but with no luck.

This leads me to believe it might be a firewall issue but I am on an Amazon Linux machine and the default policy seems to be to ACCEPT, which I checked by running iptables.

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Is there some other thing I should be checking or button I should be flipping?

My AWS Instance ID is i-0080c730c4287ca3c.

Upvotes: 5

Views: 6692

Answers (2)

Ricardo Rubik Ruiz
Ricardo Rubik Ruiz

Reputation: 107

Just in case anyone is having this problem too, make sure that you have a Gateway configured

Upvotes: 0

dmitrybelyakov
dmitrybelyakov

Reputation: 3864

I would suggest checking what access rules are defined in your EC2 instance security groups. You might need to open up port 8080.

Also, as a side note, consider not using flask development server in production like that. It's fine for testing, but you really should be using something like uwsgi for production workloads.

Upvotes: 1

Related Questions