Coding, Coffee & Chapter Notes

How to Expose Your Local Server to the Internet (Without Port Forwarding)

TL;DR:
Use Cloudflare Tunnel to make your home server accessible from anywhere. Free, secure, no router configuration needed.


I recently deployed a web app running on my laptop to a real domain.
No cloud hosting, no VPS, no monthly bills.

Just my laptop, a domain, and Cloudflare Tunnel.

Here’s exactly how I did it.


THE PROBLEM

I wanted to host my side project on my own hardware. Sounds simple, right?

But my setup had a few issues:

  • No access to the main router’s admin panel
  • Dynamic IP address
  • Port forwarding wasn’t an option

Traditional solutions like opening ports 80/443 weren’t going to work.


THE SOLUTION: CLOUDFLARE TUNNEL

Cloudflare Tunnel (formerly Argo Tunnel) creates an outbound connection from your server to Cloudflare’s edge.
No incoming ports needed.

Internet → Cloudflare (SSL) → Tunnel → Your laptop

It’s free and handles SSL automatically.


PREREQUISITES

  • A domain name (any registrar works)
  • A Cloudflare account (free tier is fine)
  • A Linux, macOS, or Windows machine running your app
  • ~10 minutes of time

STEP 1: ADD YOUR DOMAIN TO CLOUDFLARE

  1. Go to https://dash.cloudflare.com
  2. Click “Add a site”
  3. Enter your domain (e.g. myapp.com)
  4. Select the Free plan
  5. Cloudflare will show you new nameservers

STEP 2: UPDATE NAMESERVERS

Go to your domain registrar and replace the nameservers with Cloudflare’s.

Example (Porkbun):

  1. Domain Management → Your domain
  2. Nameservers → Edit
  3. Replace with Cloudflare nameservers
  4. Save and wait 5–30 minutes for propagation

STEP 3: CREATE A TUNNEL

  1. In Cloudflare, go to Zero Trust
  2. Navigate to Networks → Tunnels
  3. Click “Create a tunnel”
  4. Name it something like “my-server”
  5. Copy the installation command with the token

STEP 4: INSTALL CLOUDFLARED

Ubuntu / Debian:

<code>curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb<br>sudo dpkg -i cloudflared.deb</code>

macOS:

<code>brew install cloudflared</code>

Windows:
Download from https://github.com/cloudflare/cloudflared/releases


STEP 5: CONNECT THE TUNNEL

Run the command Cloudflare provided:

<code>sudo cloudflared service install</code>

Check status:

<code>sudo systemctl status cloudflared</code>

STEP 6: ADD A PUBLIC HOSTNAME

In Cloudflare dashboard:

  1. Open your tunnel → Configure
  2. Public Hostname → Add a public hostname
  3. Subdomain: leave empty (or use www)
  4. Domain: your domain
  5. Service Type: HTTP
  6. URL: localhost:80
  7. Save

TESTING

Open your domain in a browser or run:

<code>curl https://myapp.com</code>

SECURITY TIPS

  • Use a firewall
  • Do not expose admin panels
  • Cloudflare provides SSL automatically
  • Use Access Policies for sensitive routes

WHEN NOT TO USE THIS

  • High-traffic production apps
  • Apps requiring strict uptime
  • Sensitive data without proper security

WRAPPING UP

Cloudflare Tunnel is ideal for side projects, development environments,
self-hosted apps, and personal APIs.

No cloud bills. No port forwarding. No DevOps headache.

Leave a comment