Preview Your Localhost on the Internet in Few Seconds

Preview Your Localhost on the Internet in Few Seconds

Whether you're a front-end developer, back-end developer, or a full-stack developer you might be doing the development and seeing all the changes over localhost on respective port 3000 or 5000.

You might be wondering what if I want this live over the web. I need to get a domain, deploy everything, do the domain configuration. So, it's a lot of work for me to do.

Here's good news for you. You can tunnel your localhost easily in a few seconds to make it live.

We will be using ngrok for doing this.

Ngrok allows us to tunnel localhost. Check out more about it here

Steps to be followed to preview localhost with Ngrok

1. Create a new account on Ngrok

At first, you need to create an account on Ngrok. Ngrok provides both paid, and free plans. You can get a paid plan if that's your need.

2. Setup ngrok over your local PC

You need to install ngrok on your local PC to use it. It's just one command away.

On Ubuntu you can install with this command:

sudo snap install ngrok

Step 1, and Step 2 just need to be done once in the beginning.

3. Get your localhost live

If you have completed the above two steps then just you are just one command away to preview your local host live over the web. For example, if you are running your server at post 3000. Then, using this command you can get that live

ngrok http 3000

This will display a screen like this with the live web URL's.

Screenshot from 2021-11-14 17-05-59.png

If you are using a different post just change the port number in the above command to get it live.

This is a short tutorial but I hope you would find it useful as a developer.