Mark Locklear
Mark Locklear

Reputation: 5325

Why can't I run this node app on port 3000?

I am experimenting with a simple node app...

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/');

I am able to browse to host:1337/ and I see 'Hello World'. However, if I change the port to 3000, I can't load the page.

Upvotes: 0

Views: 1449

Answers (2)

Mark Locklear
Mark Locklear

Reputation: 5325

I changed the console log, but not the actual port number in the first argument of the listen method in this line...

}).listen(3000, "127.0.0.1");

...move along...nothing to see here! ;)

Upvotes: 0

Saurav
Saurav

Reputation: 61

You might have another service running at port 3000.

type

netstat -a -b

on the command prompt

it will list all listening ports.. check if 3000 is in use.

Upvotes: 1

Related Questions