Reputation: 99
I have a new EC2 instance in AWS where I'm hosting a webpage too. i associated the instance to a security group, and some rules work (like connect to mysql or vesta). I have created a simple server with nodeJS and I want to listen a request from port 8085 (I could choose any....). I have create a inbound rule in the security group to listen to port 8085, and it seems it wants to listen, but the connection is refused: As it is refused, I don't think it is security group problem.
This is inbound security rules:
I tried as other post mention "netstat -a -n | grep 8085" and "netstat -an | grep 8085" but I get nothing
"
I even disable firewall just in case
This is my code to create the server
const express = require('express');
const app = express();
const PORT = 8085;
app.get('/', (req, res) => {
res.send("testing");
});
app.listen(PORT, () => {
console.log(`Server running at: http://localhost:${PORT}/`);
});
When I run it I get the "Server running at http://localhost:8085/" in the console, but as when I type the IP address:8085 in the browser I get The site can't be reached. (port is not listening)
What am I doing wrong?
Upvotes: 3
Views: 3556
Reputation: 29
Try to change localhost to the private IP of your ec2 instance if you are trying to connect the instance locally with api gateway or what so ever. That worked for me .. PS: May be a bit off the track answer but could help someone
Upvotes: 0
Reputation: 99
Can you also check your VPC's Network Access Control Lists(ACLs)? There might be an explicit deny that could be blocking this Network ACLs
Upvotes: 0
Reputation: 321
I'm not much of a telnet guy, so maybe I'm missing something. You do have a connection to the machine otherwise you would get a timeout error, so your security group is ok. But notice that you are listening for http requests. As I said before I'm not a telnet guy but I don't think that you are using http protocol in the terminal, as @EdsonCSouza mentioned. Try using curl and see what you get.
Upvotes: 2
Reputation: 99
Another thing that was missing was the firewall in VESTA. I did everything again and it didn't work until i configured it.
Upvotes: 0
Reputation: 1
Your code seems ok. I tested here, your security groups seem ok too... Can you check if the node process are running when you check if the port are listening please? This is not clear from the information you have given.
Upvotes: 0