Home » Nodejs » Using NSSM to start a NodeJs process as a windows service is not working

Using NSSM to start a NodeJs process as a windows service is not working

Posted by: admin November 29, 2017 Leave a comment


I have seen countless articles on how to use NSSM (http://nssm.cc/) to start a NodeJS process.

So, I have the following simple NodeJS file:

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end('<p>Hello World</p>');

console.log('Server running on http://localhost:8000/');

I am using this command to install the NodeJS file as a windows service:

“C:\Program Files\SimpleNode\nssm.exe” install SimpleNode “C:\Program Files\SimpleNode\node.exe” “C:\Program Files\SimpleNode\simple.js”

The service is installed. When I start it I get an error message, the services is in the Paused state and I see the following error in Event Viewer:

GetProcessTimes() failed: The handle is invalid.

This should be pretty simple. I have tried using a domain account that has local admin rights. I have tried a couple of different port numbers. The app does work correctly when I start it from the command line.

This is running on 64-bit Windows 2008 R2 server. I have made sure I am running all 64-bit executables for both NSSM and Node. I have also tried using 32-bit executables for both.

Can anyone tell me what I am missing? Can someone else replicate this issue?


Found the issue.

The problem is that is that the path to the simple.js file has a space in it (Good Old “Program Files”). You have to escape the quotes with a backslash for NSSM to interpret it correctly. The correct installation command line is:

“C:\Program Files\SimpleNode\nssm.exe” install SimpleNode “C:\Program Files\SimpleNode\node.exe” \”C:\Program Files\SimpleNode\simple.js\”


It sounds like you don’t have access to ports for some reason. try setting the service to run as administrator (server Manager>Services>Servicename on windows server 2008) and see what happens.


NSSM usually works fine with Node.js so this is probably a permissions issue. Review this tutorial showing how to setup Node.js with our commercial application to troubleshoot. And feel free to use the 30-day trial too as it it may return a more helpful error message indicating what the problem is.