express.js - server listening but localhost refused to connect

Viewed 7311

Trying to get started with setting up basic server. This is my code:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
    res.send('this is fubar'); 
})

app.listen(3000, '0.0.0.0', () => console.log(`listening on port 3000`));

When I run node server.js, listening on port 3000 is logged.

But when I visit https://localhost/3000 I get the message "This site cannot be reached. Localhost refused to connect."

I ran netstat -ab | findstr :3000, but got no results. I've also tried ports 5000 and 80. What else can I do?

Using windows 10.

1 Answers

You mentioned https://localhost/3000. One problem is that it should be https://localhost:3000 (: instead of /), and another one is that you probably mean to use http on localhost. Try: http://localhost:3000

Related