Run ngrok as a Windows Service with AlwaysUp

How to Launch ngrok as a Windows Service with AlwaysUp

Establish your ngrok tunnel as soon as your computer boots and keep it open 24x7 in the background. Easily survive accidental shutdowns, crashes and other frustrating interruptions.

ngrok allows you to expose a web server running on your local machine to the Internet. It's a great solution when you need a public URL for a local resource.

To launch ngrok tunneling as a Windows Service:

  1. Download and install ngrok, if necessary.

    Be sure to connect your account (by installing your authtoken) and ensure that you can run ngrok successfully from a Windows command prompt.

    For this tutorial, we have installed ngrok (free plan) in C:\ngrok and configured the utility to provide a tunnel to our PC Commander software running on an internal server at port 8008. This command line works for us:

    C:\ngrok\ngrok.exe http https://localhost:8008

    ngrok command running

    Of course, your command line will be different — perhaps with the -config option and a .yaml file. Be sure to use your command line in the steps below.

  2. Download and install AlwaysUp, if necessary.

  3. Start AlwaysUp.

  4. Select Application > Add to open the Add Application window:

    Add Application

  5. On the General tab:

    • In the Application field, enter the full path to the ngrok executable, ngrok.exe.

    • In the Arguments field, enter the parameters to ngrok.exe (from the command line you identified step 1).

    • And in the Name field, enter the name that you will call this application in AlwaysUp. We have stuck with the default of Ngrok but you can specify another name if you like.

    ngrok Windows Service: General Tab

  6. Click over to the Logon tab, check the box at the top and enter the username and password of the Windows account where you installed ngrok. This is important if you installed your authtoken in the default configuration file (C:\Users\<USERNAME>\.ngrok2\ngrok.yml).

    ngrok Windows Service: Logon Tab

  7. If you are interested in monitoring the ngrok web interface and detecting when it stops serving pages, click over to the Monitor tab. We'll set up a failure detection batch file to detect when the web interface has failed.

    1. Follow these instructions to create the failure detection BAT file. We have called ours check-web-server.bat and placed it in our ngrok folder.

    2. Click the "..." button in the Whenever it fails a "sanity check" section and specify the full path to the batch file.

      Change the Every controls to 5 minutes, or tune to any frequency that you see fit. More time means less frequent checks and less load on the server, but with a reduced sensitivity to failures.

      Configure ngrok Sanity Check

    3. Click the OK button.

    Here's what the Monitor tab should look like when you're done:

    ngrok Windows Service: Monitor Tab

  8. Switch to the Startup tab and check the Ensure that the Windows Networking components have started box. This informs AlwaysUp that ngrok needs TCP/IP networking support to do its work.

    ngrok Windows Service: Startup Tab

  9. We're done configuring ngrok to run as a service so click the Save button to record your settings. In a few seconds, an entry for ngrok will show up in the AlwaysUp window. It is not yet running though, and the state will be Stopped:

    ngrok Windows Service: Created

  10. To start ngrok from AlwaysUp, choose Application > Start "ngrok". In a few seconds, the utility will start invisibly in the background, on the isolated Session 0. ngrok's familiar command window will NOT appear on your desktop.

    Fire up your web browser and browse to the ngrok web interface. Confirm that the tunnel is working from there:

    ngrok Windows Service: Working

  11. That's it! Next time your computer boots, ngrok will start up immediately, before anyone logs on.

    We encourage you to edit ngrok in AlwaysUp and check out the many other settings that may be appropriate for your environment. For example, send an email if ngrok crashes or stops for any reason, capture console output to a log file, restart the tunnel nightly to cure memory leaks, and much more.



ngrok not working properly as a Windows Service?

  • If accessible, review the ngrok web interface for errors and warnings.

  • Consult the AlwaysUp Troubleshooter — our online tool that can help you resolve the most common problems encountered when running an application as a Windows Service.

  • From AlwaysUp, select Application > Report Activity > Today... to bring up a HTML report detailing the interaction between AlwaysUp and ngrok. The AlwaysUp Event Log Messages page explains the messages that may turn up.

  • Browse the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips.

  • Contact us and we will be happy to help!

Download & Try it Free!

Download AlwaysUp and Run as a Service Today! Version 15.5 New!

8.0 MB Installer
Our 12,000+ customers include...
Compatible with Windows 11 Compatible with Windows Server 2022 Compatible with Windows 10
Over 94,000 installations, and counting!
 
AlwaysUp is number 1! Run as a Service with AlwaysUp

Rock-solid for the past 19+ years!