Ever wanted to show your in-progress website or app to a client without deploying it? Maybe you’re testing webhooks or just want to preview your project on another device. That’s where ngrok comes in handy. In this guide, we’ll walk you through how to share localhost professionally, step by step, so you can impress clients, test integrations, and collaborate seamlessly.


What is ngrok and Why Use It?

ngrok is a tool that creates a secure tunnel from your local machine to the internet. Essentially, it lets anyone access your locally running server via a public URL.

Some key reasons to use it:

  • Client demos: Let clients preview your work before deployment.
  • Webhook testing: Services like Stripe, PayPal, or GitHub often require public URLs for callbacks.
  • Cross-device preview: Test your project on your phone or tablet without deploying it online.
  • Secure sharing: ngrok tunnels are HTTPS-ready, keeping your local environment safe.

In short, learning how to share localhost with ngrok saves time, reduces deployment stress, and makes client presentations smoother.


Installing and Setting Up ngrok

Step 1: Install ngrok

Windows: Download the ZIP from ngrok.com, extract it, and place the executable in a folder on your PC.
macOS: Use Homebrew:

brew install --cask ngrok

Linux: Download the package for your distro and follow the installation instructions.


Step 2: Connect Your Account

Sign up at ngrok.com, get your auth token, and connect it via terminal:

ngrok authtoken <your_auth_token>

This ensures your tunnels are tied to your account, unlocking extra features.


Step 3: Start Your Local Server

Run your project locally. For example:

npm start

Your app might run on port 3000, 5000, or any custom port.


Step 4: Share Your Localhost

To expose your server:

ngrok http 3000

You’ll get a URL like https://12345.ngrok.io that you can share. Easy, right?

💡 Pro Tip: If your terminal stops running, the ngrok link will stop working unless you’re on a paid plan. Keep this in mind when showing clients!


Running Multiple Tunnels at Once (Cheat Code!)

Want to expose multiple servers at the same time? Here’s a cheat I personally use. Create a YAML config file, e.g., ngrok.yml:

version: "2"
authtoken: 4gsuuiu66hgy35rghsbjgtrt5wghndbhgdhghddx

tunnels:
  frontend:
    proto: http
    addr: 3000

  backend:
    proto: http
    addr: 5000

Then run:

ngrok start frontend backend --config "C:\Users\YourName\Documents\ngrok.yml"

💡 Replace the path with where you saved your YAML file and replace the authtoken with yours. Now you have multiple links running simultaneously, super handy for full-stack projects!


Tips for Smooth Sharing

  • HTTPS first: Secure your tunnel with HTTPS using ngrok http https://localhost:3000.
  • Inspect traffic: ngrok provides a web interface at http://127.0.0.1:4040 to debug requests.
  • Monitor tunnels: Check analytics on ngrok dashboard.
  • Firewall: Make sure outgoing traffic on your ports is allowed.
  • Persistent URLs: For stable URLs that don’t change every time you restart, ngrok premium is the way.

Alternatives to ngrok

While ngrok is popular, a few alternatives exist if you want options:

  • Localhost.run: Simple SSH-based solution.
  • Serveo: Lightweight and straightforward.
  • Pagekite: Good for exposing local servers to the internet securely.

These tools work similarly but may have different limitations.


Read also: How to Create an Email Contact Form Without a Database (Using Formspree & Other Options)

Conclusion

Sharing your local development environment doesn’t have to be complicated. Using ngrok, you can easily show clients your work, test integrations, and collaborate like a pro. By following this guide, you now know how to share localhost securely and efficiently, even running multiple tunnels at the same time using a config file.

With this setup, your local projects become accessible anywhere, anytime without risking your development environment.

FAQ About How to Share Localhost With Ngrok

1. Do I need ngrok premium?

Not necessarily. Free accounts are perfect for quick demos. Premium is useful for persistent URLs and advanced features.

2. What happens if I close my terminal?

The ngrok tunnel stops. Only premium users can keep tunnels alive without keeping the terminal open.

3. Can I expose multiple servers at once?

Yes! Use the YAML config method above to run multiple tunnels simultaneously or pay for premium.

4. Is it safe to share localhost via ngrok?

Absolutely. ngrok tunnels are secure, and you can use HTTPS to encrypt all traffic.

5. Can I use ngrok for mobile testing?

Yes! Just share the public URL generated by ngrok, and you can access your project on any device connected to the internet.