Can't access port 8080 on EC2 (AWS)

2019-06-25 10:33发布

I just started a new AWS EC2 instance. In the instance's security group I added a new rule to open port 8080. I also stopped the iptables service on the instance, per another post. So in theory this port should be wide open.

I started my RESTful service on 8080 and was able to access it locally via curl.

When I come in with curl remotely I get an error saying it couldn't connect to the host.

What else should I check to see if 8080 is truly open?

1条回答
戒情不戒烟
2楼-- · 2019-06-25 10:49

I started my RESTful service on 8080 and was able to access it locally via curl.

What kind of technology is your RESTful service based upon?

Many frameworks nowadays listen on localhost (127.0.0.1) only, be it by default or by means of their examples, see e.g. the canonical Node.js one (I realize that port 8080 hints towards Java/Tomcat, anyway):

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

The log message generated by starting this is Server running at http://127.0.0.1:1337/ - the emphasized part is key here, i.e. the server has been configured to listen on the IP address 127.0.0.1 only, whereas you are trying to connect to it via your public Amazon EC2 IP Address.

查看更多
登录 后发表回答