Changing Node.js listening port

I just installed node.js on Windows. I have this simple code which does not run:

I get: Error: listen EADDRINUSE

Is there a config file that tells node.js to listen on a specific port?

The problem is I have Apache listening on port 80 already.


var http = require('http'); 
var url = require('url'); 

http.createServer(function (req, res) { 
 console.log("Request: " + req.method + " to " + req.url); 
 res.writeHead(200, "OK"); 
 res.write("<h1>Hello</h1>Node.js is working"); 
console.log("Ready on port 5454");


There is no config file unless you create one yourself. However, the port is a parameter of the listen() function. For example, to listen on port 8124:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8124, "");
console.log('Server running at');

If you're having problems finding a port that's open, you can go to the command line and type:

netstat -ano

To see a list of all ports in use per adapter.

I usually manually set the port that I am listening on in the app.js file (assuming you are using express.js

var server = app.listen(8080, function() {
    console.log('Ready on port %d', server.address().port);

This will log Ready on port 8080 to your console.

you can get the nodejs configuration from The important thing you need to keep in your mind is about its configuration in file app.js which consists of port number host and other settings these are settings working for me

backendSettings = {
"scheme":"https / http ",
"host":"Your website url",
"port":49165, //port number 
'sslKeyPath': 'Path for key',
'sslCertPath': 'path for SSL certificate',
'sslCAPath': '',
"baseAuthPath": '/nodejs/',
"scheme": 'https / http', //whatever is your website scheme
"host":"host name",
"addUserToChannelUrl": 'user/channel/add/:channel/:uid',
"publishMessageToContentChannelUrl": 'content/token/message',

In this if you are getting "Error: listen EADDRINUSE" then please change the port number i.e, here I am using "49165" so you can use other port such as 49170 or some other port. For this you can refer to the following article

Need Your Help

Constructor overload in TypeScript

typescript constructor overloading

Has anybody done constructor overloading in TypeScript. On page 64 of the language specification (v 0.8), there are statements describing constructor overloads, but there wasn't any sample code giv...

Rails Validation for users email - only want it to validate when a user signs up or updates email address

ruby-on-rails validation models

I have a User model with the usual attributes such as email and hashed_password etc. I want to write a validation that checks for the presence of an email address but only when