Taking localhost To Internet

There can be many situations where you may want to get your localhost to internet. I was working on a project recently that involved using stripe. When working with tools like stripe that involves money transfers you need to listen to all the events generated in the process. Solution to that is a webhook. However the problem is, when in development, webhooks cannot connect (POST data) to your localhost. Therefore you need a way to take your localhost (development environment) to the internet.

Other such instance can be when you are designing a website for some remote client. You have completed all the development in your localhost, but before hosting the site your client needs to review it. You again need to somehow take your localhost to internet so that your client who is sitting in the other part of the world can review it.  There can be many such occasions like these.

There are several tools available for this purpose. Some of the prominent ones are: ngrok, PageKite and ProxyLocal. I however use ngrok, so this post will explain only about using ngrok in the simplest possible way.

ngrok is simple to use and hardly takes a minute to get started. It comes both as a free as well as paid service, we however will focus only on the free service.  To get started, you need to download the binary file from here. As the official website says, “a single binary with zero run-time dependencies for any major platform” and that’s all you need to get started.

Download the file to any preferred location and unzip it. On unziping you will get a binary file named ‘ngrok’ and that’s it!

Now to get your localhost online simply run the file with the desired port number. In most of the cases the port number will be 80 (default HTTP port).  In such case run:

./ngrok 80

And done! Your localhost is now on the internet. The above command will output something like this:



The address mentioned as Forwarding is the one you can use to access the localhost on the internet. In this case: http://16f3e567.ngrok.com

Similary say you are working on a rails project. As webrick’s default port is 3000, you will run:

./ngrok 3000

The output will be like:

ngrok 3000


Also you may notice, ngrok provides a web interface too that can be accessed on address:

Stop the tunneling by: Ctrl + c

Hope this helps you! 🙂


One thought on “Taking localhost To Internet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s