Skip to content
Advertisement

AWS EC2 instance connection refused on port 8085

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.

enter image description here

This is inbound security rules:

enter image description here enter image description here

I tried as other post mention “netstat -a -n | grep 8085” and “netstat -an | grep 8085” but I get nothing enter image description here

I even disable firewall just in case enter image description here

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?

Advertisement

Answer

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.

Advertisement