roncook
roncook

Reputation: 397

express.js - server listening but localhost refused to connect

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.

Upvotes: 3

Views: 9811

Answers (1)

Andre Pena
Andre Pena

Reputation: 59336

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

Upvotes: 6

Related Questions