Auto start node.js server on boot


Can any node.js experts tell me how I might configure node JS to autostart a server when my machine boots? I'm on Windows

This question is tagged with node.js

~ Asked on 2013-12-07 19:28:31

The Best Answer is


This isn't something to configure in node.js at all, this is purely OS responsibility (Windows in your case). The most reliable way to achieve this is through a Windows Service.

There's this super easy module that installs a node script as a windows service, it's called node-windows (npm, github, documentation). I've used before and worked like a charm.

var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
  name:'Hello World',
  description: 'The example web server.',
  script: 'C:\\path\\to\\helloworld.js'

// Listen for the "install" event, which indicates the
// process is available as a service.



I found the thing so useful that I built an even easier to use wrapper around it (npm, github).

Installing it:

npm install -g qckwinsvc

Installing your service:

> qckwinsvc
prompt: Service name: [name for your service]
prompt: Service description: [description for it]
prompt: Node script path: [path of your node script]
Service installed

Uninstalling your service:

> qckwinsvc --uninstall
prompt: Service name: [name of your service]
prompt: Node script path: [path of your node script]
Service stopped
Service uninstalled

~ Answered on 2013-12-22 00:06:39


If you are using Linux, macOS or Windows pm2 is your friend. It's a process manager that handle clusters very well.

You install it:

npm install -g pm2

Start a cluster of, for example, 3 processes:

 pm2 start app.js -i 3

And make pm2 starts them at boot:

 pm2 startup

It has an API, an even a monitor interface:


Go to github and read the instructions. It's easy to use and very handy. Best thing ever since forever.

~ Answered on 2013-12-18 14:39:21

Most Viewed Questions: