Keep NATS Server Windows Service running 24/7 with Service Protector

How to Keep your NATS Server Windows Service Running 24/7 with Service Protector

Automatically restart NATS Server whenever it stops, crashes or has trouble serving TCP/IP requests. Ensure that your visualization subsystem is always available.

NATS Server is a key component of the open-source NATS cloud native infrastructure messaging system.

On Windows, NATS Server is typically installed as a service. That allows the software to start automatically whenever your computer boots and run continuously in the background:


To monitor & protect the NATS Windows Service with Service Protector:

  1. Download and install Service Protector, if necessary.

  2. Start Service Protector.

  3. Select Protector > Add to open the Add Protector window:

    Add Protector

  4. On the General tab, in the Service to protect field, select the NATS Server windows service. It's called nats-server on our machine:

    NATS Server Windows Service: General Tab

  5. To automatically restart NATS Server if it encounters a networking problem, switch to the Monitor tab. We'll set up a sanity check to shout if the NATS Server stops accepting network requests.

    1. First, check the Whenever it fails a periodic sanity check box and click the Set button:

      Docker Engine Windows Service: Monitor Tab

    2. In the Add Sanity Check window, select the Check that a network server is accepting connections option and click Next to proceed:

      Add a network connection sanity check

    3. Leave "localhost" in the Host name field and enter the port number where NATS server is listening. By default, that's 4222:

      Enter the Host Name and Port for NATS Server

      Click Next to continue.

    4. Specify how often Service Protector should check that NATS Server is responsive. Every 5 minutes should be enough:

      Set the NATS Server Sanity Check frequency

      After you're done, click Next to move on.

    5. And finally, confirm your settings:

      Confirm your sanity check settings

      If everything looks good, click Add to record your new sanity check and bounce back to the Monitor tab. There will be a green check mark beside the Set button:

      NATS Server Windows Service: Monitor Tab (Complete)

  6. Click the Save button to record your settings. In a few seconds, a new entry will appear in the Service Protector window.

    The green shield indicates that Service Protector is already actively monitoring NATS Server to detect failures:

    NATS Server Windows Service: Protected

    If you want to see how the NATS Server service is performing, click the green "Running" circle:

    NATS Server Windows Service: Information

  7. That's it. Next time your computer boots, NATS Server will start automatically and Service Protector will babysit the service to promptly restart it if it stops for any reason.

    We encourage you to edit your NATS Server entry in Service Protector and browse through the many other settings that may be appropriate for your environment. For example, send an email when the service fails, schedule a regular restart to cure annoying memory leaks, and much more.



Trouble protecting the NATS Server Windows Service?