How to expose localhost to any device using Ngrok

Want to know how you can easily test your design without deploying or hosting it anywhere?

Use to expose your localhost

How it works


Go over to the ngrok download page. It will automatically detect your OS and show you the option to download the binary file. Unzip the downloaded zip file, you can find the executable there.

Sign in to ngrok

You need an authtoken to use the service. Sign up is easy. In your dashboard you will find the code to run the token.

$ /path/to/ngrok authtoken <YOUR_AUTH_TOKEN>

The /path/to is easy, if you can just move or copy the binary to your home directory or run ./ngrok authtoken <YOUR_AUTH_TOKEN> from the directory the file resides.

Starting ngrok

Now if you have your server running at http://localhost:3000 then run

./ngrok http 3000

That's it. You will get the process running status and urls like this:

console and mapping of urls

You'll get http as well as https connection to the webserver.

Hope you'll find something useful here.
Frontend developers can find this very useful to access a variety of mobile devices anywhere as long as the connection is alive. One thing to remember is that in the free plan we don't get to choose a custom domain. But that's okay in most cases.

Subscribe to newsletter
Need more tech news? Tune in to our weekly newsletter to get the latest updates