How to expose localhost to internet

Internet. One of the most outstanding place on the earth. Wait, is the internet real “place” and really “on earth”?

Don’t worry, I am stopping here and will not ask stupid questions no more.

If you’ve ever been coding a website and had to expose it to internet from your localhost, well, it was not possible.

Currently there are tools that create some kind of a tunnel between your computer and the internet so as your local network is really accessible from anywhere on the earth.

On of my most favourite tools is ngrok. Ngrok allows you exactly what I wrote earlier. It allows to expose a localhost server to the internet.


  • you are running php artisan serve to develop a laravel app
  • you are using http-server node package to run your javascript app
  • you are running webpack-dev-derver to develop your javascript app

Every single instance of the examples above can be mixed with ngrok to made it public to the internet.


Step 1

Create a web server

The very first thing is to create a webserver n your local network. It does not matter if it is nginx, apache, http-server or just plain silly php -S The only requirement is that it needs to be available on your local network on a specific port number.

Step 2

Run ngrok

In this step you are going to run ngrok to initialize a connection between your local network and the internet.

You do that by using the command ngrok http {port}, where {port} is the port number that your local webserver uses.


  • php artisan serve --port=1280 and ngrok http 1280
  • http-server -p 8080 and ngrok http 8080
  • …and so on

Wrap up

This is is. That easily you can expose your local network to the internet.

Hope this helps.


Leave a comment

Your email address will not be published. Required fields are marked *