How to Test Local Websites or Apps on Internet Using Ngrok

Are you a website or mobile application developer, and want to expose your localhost server behind a NAT or firewall to the public Internet for testing purposes? In this tutorial, we will reveal how to do this securely using ngrok.

Ngrok is a sensational, free open source and cross-platform reverse proxy server for exposing local servers behind NATs and firewalls to the public Internet over secure tunnels. It is a remarkable computer program that you can use to implement personal cloud services directly from home.

It essentially establishes secure tunnels to your localhost, thus enabling you to: run demos of web sites before actual deployment, testing mobile apps connected to your locally running backend and building web-hook consumers on your development machine.

Ngrok Features:

  • Easy install with zero run-time dependencies for any major platform and works fast.
  • Supports secure tunnels.
  • Captures and analyzes all traffic over the tunnel for later inspection and replay.
  • Allows you to do away with port forwarding in your router.
  • Enables implementing of HTTP authentication (password protection).
  • Uses TCP tunnels to expose networked service that do not use HTTP such as SSH.
  • Supports tunneling only HTTP or HTTPS with SSL/TLS certificates.
  • Supports multiple simultaneous tunnels.
  • Allows for replaying webhook requests.
  • Enables you to work with virtual-host sites.
  • It can be automated via an API plus many options in the paid plan.

Before using it, you need to have a web server installed or consider setting up a functional LAMP or LEMP stack, otherwise follows these guides to:

Install LAMP Stack on Linux:

  1. Installing LAMP (Linux, Apache, MariaDB, PHP/PhpMyAdmin) in RHEL/CentOS 7.0
  2. How to Install LAMP with PHP 7 and MariaDB 10 on Ubuntu 16.10

Install LEMP Stack on Linux:

  1. How to Install LEMP (Linux, Nginx, MariaDB, PHP-FPM) on Debian 9 Stretch
  2. How To Install Nginx, MariaDB 10, PHP 7 (LEMP Stack) in 16.10/16.04
  3. Install Latest Nginx, MariaDB and PHP on RHEL/CentOS 7/6 & Fedora 20-26

How to Install Ngrok in Linux

Ngrok is super easy to install, simple run the commands below to download and unzip the archive file which contains a single binary.

$ mkdir ngrok
$ cd ngrok/
$ wget -c
$ unzip
$ ls
Download Ngrok Tool
Download Ngrok Tool

Once you have the binary file, let’s create a basic index.html page in the web server’s (Apache) default document root for testing requests to the web server.

$ sudo vi /var/www/html/index.html

Add the following HTML content in the file.

<!DOCTYPE html>
                <h1>This is a Dummy Site</h1>
                <p>We are testing Ngrok reverse proxy server.</p>

Save the file and launch ngrok by specifying the http port 80 (if you have configured you web server to listen on another port, you need to use that port):

$ ngrok http 80

Once you start it, you should see an output similar to the one below in your terminal.

Launch Ngrok on Terminal
Launch Ngrok on Terminal

How to Inspect Traffic to Your Web Server Using Ngrok UI

Ngrok offers a simple web UI for you to inspect all of the HTTP traffic running over your tunnels in real-time.

Ngrok Web Interface
Ngrok Web Interface

From the output above, no requests have been made to the server yet. To get started, make a request to one of your tunnel using the URLs below. Other user will also use these addresses to access your site or app. 
Check Local Website Over Ngrok
Check Local Website Over Ngrok

Then check from the inspection UI to get all of the details of the request and response including the time, client IP address, duration, headers, request URI, request payload and the raw data.

Check Website Requests
Check Website Requests

For more information, see the Ngrok Homepage:

Ngrok is simply an amazing tool, it is by far the simplest yet powerful secure local tunnel solution you will find out there. You should consider creating a free ngrok account to get more bandwidth, but if you want even more advanced features, try upgrading to a paid account. Remember to share your thoughts about this piece of software, with us via the comment form below.

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

4 thoughts on “How to Test Local Websites or Apps on Internet Using Ngrok”

  1. Its useful but only allow the few web requests and then ask for the PAID service. If you looking for the open-source then don’t try this.


Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.