How to Run NodeJS Application as a Windows Service

In a development environment, it’s very easy to run your server using a simple command but in a production environment, your Node application needs to be up and running at all times.

To run a Node application as a Windows service, you need to leverage another third-party tool. The best and the easiest one to configure in this case would be NSSM.

What does NSSM offer?

Once you install and configure NSSM for your Node.js application, you can be assured that your server will run forever as a background service.

Here are the most salient features of NSSM:

  • NSSM is a free and open source software
  • It converts executables into Windows services
  • NSSM can manage the CPU affinity and process priority of the managed application
  • It acts as a Load balancer for your services
  • NSSM monitors the services at all times. Whenever there’s a failure or machine reboots, it will automatically start the services

How to run Node server as a Service using NSSM

Here are step-by-step instructions with screenshots on how to install and use NSSM to ensure the availability of your Node application server at all times:

Step-1: Download NSSM

You can download the latest package of NSSM from HERE.

If you’re running Windows 10, you should download the latest pre-release build to avoid any problems.

NSSM download

Step-2: Renaming and placing the NSSM folder in C: drive

It’s not a compulsory step but it’s better to rename the folder to a simple name and place it in the C: drive for better accessibility.

For this exercise we are going to name the folder “nssm” and move it to the main C: drive.

NSSM placement

Step-3: Creating a Service for your Nodejs Application

The next step is to create a Windows service using NSSM for your Node application. Follow the procedure step-by-step and make sure to get the locations of the folders right.

  1. Open the command prompt and make sure to run as Administrator.
  2. Traverse to the path where nssm.exe is located. If you followed the previous step it should be located in C:\nssm\nssm\win64 (If your Windows is 4-bit).
    NSSM Location
  3. Assuming you have Nodejs installed in the default folder (C:\Program Files\nodejs), you need to enter the following command in the command prompt: (app is the service name that you want to assign for your Node application)
    NSSM install
  4. Now we need to set the App Directory for the Nodejs app that you need to run as service. Assuming the App is located at: D:\app Enter this command:
    NSSM App directory
  5. Once that’s done, you need to set the App parameters to the server.js file that needs to run every time. Here’s the command to do that:
    NSSM App Parameters
  6. Now finally, you can initiate the new service with the command:
    NSSM start app

And that is it! Your Nodejs app will now run as a background Windows service. If anything fails or your machine boots up, the application will launch automatically, ensuring maximum availability for your Node application.

Additional Resources

  • How to run any Application as a Windows Service (Step-by-step)
Spread the Word

You May Also Like

About the Author: Umair

A self-learned Javascript developer specializing in Frontend and Backend frameworks including React.js, Redux, Node.js, Express, MongoDB. He has extensive industry experience as a Tech Support lead and System Administrator. Currently learning Web3, (Solidity, Hardhat, Ethers.js) Smart contracts development, testing and auditing.


  1. m getting below error while starting “nssm start app”
    app: Unexpected status SERVICE_STOPPED in response to START control.

    1. I had this happen too. Try changing the file names so everything matches before following the instructions.

    1. You can use the this Powershell command to get the list of services created using nssm:
      Get-WmiObject win32_service | ?{$_.PathName -like '*nssm*'} | select Name, DisplayName, State, PathName

  2. Development on NSSM appears to have halted years ago. Is this still a viable solution with no support for bug fixes?

  3. I am about the trial this in lab but have question on how to use if I have multiple Node scripts?
    Can you name the service this is linked to the JS script? I have need to run two app simultaneously

  4. I have figured this out in step 3 (app) – This is the Name that will appear in the Services listing and path to executable is the nssm.exe.

    My JS appear is now working which is grand!!!

  5. when i used node red using nssm as service , why i can not run execute file (ex:notepad.exe) using exec node?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.