Skip to main content
All CollectionsSupport
How to test localhost using a tunneled connection
How to test localhost using a tunneled connection

How to test your local environment (localhost) using NGrok

I
Written by Igor Ivanovski
Updated over a week ago

How to make your laptop’s web server publicly accessible

If you don’t have time to setup a testing server, there is a simple solution: setup a tunnel from your laptop or development computer to the public internet using NGrok. When you need to reconnect, when changing your laptop’s connection for example, simply run NGrok again and learn your new public URL.

Here we show you how to make your local environment’s web server visible to the public internet. After doing this you can use a cloud based service like Usetrace to test your web app that is on your own laptop. This solution should work with connections behind firewalls or NAT.

1. Download NGrok

2. Run NGrok to setup the tunnel

Linux

Open up terminal and run NGrok with “./ngrok http 8000” to share your server located on localhost:8000

Windows

Start NGrok by using a command prompt to share your server located on localhost:8000 on Windows with

ngrok http 8000

Mac

You need to allow NGrok to run in OS X.

Open the terminal:

Set security settings

Mac OSX has security policy which by default forbids running software that is not installed from the Mac App Store or it doesn’t have Apple granted Developer ID signature. (you can read more about it on support.apple.com/en-us/HT202491).

To allow your tunnel software NGrok to run, first create a new policy with command

spctl --add --label "MyTunnel" /Users/lilligunnar/Downloads/ngrok

Then allow this group to run with command

spctl --enable --label "MyTunnel"

Allow the changing of security settings

A popup window should appear asking for your username and password. Enter them to allow NGrok to run.

Launch NGrok

To share your server located on localhost:80 type

./ngrok http 80

3. Learn your new public URL

Finally, when NGrok is running, copy the https address after “Forwarding” from the terminal. This is your web server that is now publicly available through NGrok. Usetrace can now be pointed to this address (base URL). See How to set the default base URL.

To stop sharing your server quit the NGrok process.

Did this answer your question?