Logo

dev-resources.site

for different kinds of informations.

Expose Your Localhost to a Public URL

Published at
12/17/2024
Categories
webtool
localhost
tunnel
Author
devatsrs
Categories
3 categories in total
webtool
open
localhost
open
tunnel
open
Author
8 person written this
devatsrs
open
Expose Your Localhost to a Public URL

When developing a local application, you might want to share it with others remotely or test it on external devices. Here are three popular tools—ngrok, Localtunnel, and Cloudflare Tunnel—for creating a public URL for your local server.


1. Using ngrok

ngrok is a popular tool that creates secure tunnels, supporting HTTP, HTTPS, and TCP protocols.

Step 1: Install ngrok

  1. Visit ngrok’s official website and download the latest version of ngrok for your OS.
  2. Unzip the downloaded file and move the ngrok executable to a directory included in your system's PATH.

Step 2: Set Up ngrok Authentication

  1. Sign up on ngrok to get an authentication token (this is required for free users to use ngrok).
  2. Run the following command in your terminal:

    ngrok authtoken <your_auth_token>
    

Step 3: Start an ngrok Tunnel

  1. In your terminal, navigate to the directory where your local server is running.
  2. Run the following command (replace 3000 with your server’s port):

    ngrok http 3000
    
  3. You’ll see a public URL like https://<random_string>.ngrok.io in the terminal. Use this URL to access your localhost from anywhere.

Pros: Secure, widely used, supports multiple protocols.

Cons: Free version has a limited session time and random URLs.


2. Using Localtunnel

Localtunnel is a simple and free solution that requires minimal setup. It’s ideal for quickly sharing local apps temporarily.

Step 1: Install Localtunnel

  1. Make sure you have Node.js installed, as Localtunnel is an npm package.
  2. Install Localtunnel globally with this command:

    npm install -g localtunnel
    

Step 2: Start a Localtunnel Session

  1. Open your terminal and navigate to the directory where your local server is running.
  2. Run the following command (replace 3000 with your server’s port):

    lt --port 3000
    
  3. You’ll get a URL like https://<random_string>.loca.lt that you can share.

Pros: Easy setup, no registration required.

Cons: URLs are random; no advanced security features.


3. Using Cloudflare Tunnel (Argo Tunnel)

Cloudflare Tunnel (previously Argo Tunnel) is a secure way to expose your localhost, protected by Cloudflare’s security features. It’s great for long-term use.

Step 1: Install Cloudflare’s CLI Tool

  1. If you’re on macOS, run the following command to install Cloudflare’s CLI (cloudflared):For other operating systems, visit Cloudflare Tunnel’s documentation to find the appropriate installer.

    brew install cloudflared
    

Step 2: Start a Cloudflare Tunnel

  1. Run the following command to start a tunnel (replace 3000 with your server’s port):

    cloudflared tunnel --url http://localhost:3000
    
  2. Cloudflare will provide you with a public URL associated with your Cloudflare account.

Pros: Secure, reliable, and good for long-term access.

Cons: Initial setup can be slightly more involved.


Summary Table

Tool Installation Difficulty Security URL Type Best Use Case
ngrok Easy High Random (free) General, short-term sharing
Localtunnel Very easy Medium Random Quick, temporary use
Cloudflare Tunnel Moderate Very High Permanent (with account) Long-term, secure projects

Each tool offers unique advantages for sharing your localhost. Choose the one that best fits your needs, whether it’s a quick test or a more permanent, secure solution.

Key Takeaways of Using Tunneling Tools like above

Ease of Sharing Local Servers

  • Instantly share your development environment with external collaborators or testers without deployment.
  • Access your app using a secure, public URL.

Cross-Device Testing

  • Test locally hosted applications on external devices like phones, tablets, or other machines in different networks.
  • Ensure compatibility across multiple devices and environments.

Convenient Collaboration

  • Demonstrate app functionality to clients or stakeholders without deploying to a staging or production server.
  • Collaborators can interact with the live local app in real time.

Free to Start

  • All tools provide free tiers suitable for most personal and small-team use cases.
  • Cost-effective for occasional remote access needs.

Minimal Setup

  • Simple to install and run with minimal configuration, typically requiring just a single command to start.

Using tools like ngrok, Localtunnel, and Cloudflare Tunnel enables rapid prototyping, collaboration, secure testing, and integration debugging, all while saving time and effort during local app development. These tools eliminate deployment barriers, helping developers focus on building and testing features without worrying about infrastructure setup.


tunnel Article's
24 articles in total
Favicon
Using Cloudflare Tunnel to public Ollama on the Internet
Favicon
Expose Your Localhost to a Public URL
Favicon
Connecting streamtasks over the Internet
Favicon
Cat Tunnel Tree Skirt
Favicon
Cloudflare's ZeroTrust Part 1: How can I access to my web/app in private network without NAT
Favicon
List of ngrok/Cloudflare Tunnel alternatives and other tunneling software and services. Focus on self-hosting.
Favicon
KubeVPN offers a Cloud-Native Dev Environment that seamlessly connects to your Kubernetes cluster network.
Favicon
How Cloudflare tunnel work(part-2)
Favicon
Hop, Skip and a Jump
Favicon
Tunnel between hosts without public IPs
Favicon
Upload files to Azure Virtual Machines with Azure Bastion in tunnel mode
Favicon
Building a HTTP Tunnel with WebSocket and Node.JS Stream
Favicon
Expose your web server on GitHub Actions to the internet using Cloudflare Tunnel
Favicon
java-ngrok - a Java wrapper for ngrok
Favicon
[UPDATE] มุด Proxy ย้อนกลับ
Favicon
SSH setup and tunneling via Bastion host
Favicon
A Free Cloudflare Tunnel running on a Raspberry Pi
Favicon
มุด Proxy ย้อนกลับ
Favicon
pyngrok — a Python wrapper for ngrok
Favicon
SSH Port forwarding localhost request to the world
Favicon
Saas- Idea to Reality
Favicon
Use a Jump Server for a Secure Tunnel to Lightsail Databases
Favicon
Access inaccessible: SSH tunnelling 🔥🔥🔥
Favicon
Working with webhooks using ngrok

Featured ones: