DEV Community

Cover image for Host your website locally to show everyone
Bogusdeck
Bogusdeck

Posted on • Updated on

Host your website locally to show everyone

Have you ever wanted to share a website you're developing on your local machine with someone else? Or perhaps you need to demo a project to a client or a colleague without deploying it to a public server? This is where LocalTunnel comes to the rescue. In this guide, we'll walk through the steps of using LocalTunnel to expose your locally hosted website to the internet, making it accessible to anyone, anywhere

What is LocalTunnel?

LocalTunnel is a powerful tool that allows you to expose your local development server to the internet. It creates a secure tunnel to a public URL, enabling others to access your locally hosted website as if it were live on the web.

Let's Setup

Install nodejs and npm in your system

  • For Windows and mac OS
    nodejs.org

  • For Linux

    • Ubuntu/debian

      sudo apt update
      sudo apt install nodejs npm
      
    • Arch linux

      sudo pacman -S nodejs npm
      

Install local tunnel

Open your terminal and run the following command to install localtunnel globally

npm install -g localtunnel
Enter fullscreen mode Exit fullscreen mode

localtunnel install image

Start your Local Server

start your application or website on local development server

server start image

Use localtunnel

In your Terminal , run the following command

lt --port <your_local_port>
Enter fullscreen mode Exit fullscreen mode

For example
if website or application is hosted on local host i.e port 3000

lt --port 3000
Enter fullscreen mode Exit fullscreen mode

localport

LocalTunnel will generate a unique URL which you can share with others to access your locally hosted website

Some advance options

Custom Subdomain

lt --port <your_local_port> --subdomain <your_custom_subdomain>
Enter fullscreen mode Exit fullscreen mode

subdomain

Allowing specific hostnames

lt --port <your_local_port> --host <allowed_hostname>
Enter fullscreen mode Exit fullscreen mode

Setting Maximum Connections

lt --port <your_local_port> --max-conn 3
Enter fullscreen mode Exit fullscreen mode

Specifying Base Domain

lt --port <your_local_port> --domain <your_domain>
Enter fullscreen mode Exit fullscreen mode

💡 Be mindful when using LocalTunnel, as it's convenient but may pose security risks. Avoid exposing sensitive information, and make certain your local server is secure, preventing any inadvertent exposure of confidential data to the public.

Top comments (1)

Collapse
 
afifudinmtop profile image
Afifudin Maarif

thanks