Blog · · The Expose team
Hosting from localhost: how to put a site on your machine on the internet
Put a site on localhost on the internet: a tunnel in one command, port forwarding on your router, or a deploy. Which one you need, with the commands.
Your project runs on http://localhost:3000 and you want someone else to open it: a client, a friend, a webhook provider, your phone. Sending them that link doesn't work. localhost is the loopback address, 127.0.0.1, so on their device it points at their own computer, not yours.
There are three ways to put it online:
-
A tunnel gives the local site a public HTTPS URL in seconds. You don't touch your router. Use it for demos, webhooks and testing on other devices:
expose share http://localhost:3000 -
Port forwarding on your router sends incoming connections to your computer. It needs access to the router and a public IPv4 address, and keeping it safe is your job.
-
A deploy puts the site on a server, which you need if it has to stay up while your laptop sleeps. This is the only one of the three that counts as hosting.
If the other person is on the same Wi-Fi, you don't need the internet at all: expose share http://localhost:3000 --lan.
Which one do you need?#
| Who needs to reach it | How long | Use |
|---|---|---|
| Your phone, or a colleague on the same Wi-Fi | While you work | --lan, below |
| A client, a friend, a tester | For a demo or a review | A tunnel |
| Stripe, GitHub, Shopify, an OAuth provider | While you develop | A tunnel |
| Real visitors | All the time | A deploy |
| A home server you want online for good | All the time | Port forwarding, or a server you rent |
One question settles most cases: does it have to work when your computer is off? If it does, deploy it. A tunnel and port forwarding both serve the site from your machine, so when you close the lid, the site goes offline.
Option 1: a tunnel, the fastest way to make localhost public#
A tunnel client on your machine opens an outgoing connection to a server that has a public address. That server gives you a public URL and sends every request for it back through the connection to your local site.
Your router only sees an outgoing connection, the same as a browser tab. So a tunnel works behind firewalls, VPNs, double NAT and carrier-grade NAT (CGNAT), and on networks you don't control, such as an office, a café or a phone hotspot.
Install Expose#
On macOS and Linux:
curl -fsSL https://expose.dev/install.sh | sh
On Windows, in PowerShell:
irm https://expose.dev/install.ps1 | iex
With Homebrew, run brew install --cask expose. Laravel Herd already includes Expose. Expose is a single binary for macOS, Linux and Windows with no dependencies, so you don't need PHP or Node.js. The installation docs cover the details.
Share the site#
Give Expose the URL you open in your own browser:
# A dev server on a port: Next.js, Vite, Rails, Django, Go, anything
expose share http://localhost:3000
# A Laravel Herd or Valet site
expose share my-app.test
# A site that already runs on HTTPS locally
expose share https://my-app.test
The first time, Expose opens your browser so you can sign in or create a free account, and then it shares the site. It prints the public HTTPS URL. Send that URL to whoever needs it.
Each request to that URL goes through the tunnel to your machine, and your dev server answers it as usual. Expose itself connects to localhost, so your server can keep listening on 127.0.0.1 only. Visitors get your site directly: Expose shows no warning page in front of it, on any plan.
While you share, http://127.0.0.1:4040 shows every request that came in, with its headers, body and response. You can replay a request without triggering it again, which helps when a webhook fails. See the request dashboard.
The URL only works while expose runs. Stop the command and the URL stops answering. For a service that doesn't speak HTTP, such as SSH or a database, expose share-port 22 shares a TCP port. The sharing docs list every way to share.
Framework settings to check first#
Some dev servers reject requests for a hostname they don't recognise. Here is what to change:
- Vite. If you see "Blocked request. This host is not allowed.", add
.sharedwithexpose.comtoserver.allowedHosts. See the Vite guide. - Next.js. If hot reloading stops through the tunnel, add
*.sharedwithexpose.comtoallowedDevOrigins. See the Next.js guide. - Laravel. If links come out as
http://, trust the proxy in your local environment. Ifnpm run devis running, Expose shares Vite's dev server too, so CSS and hot reloading work through the tunnel. See the Laravel guide.
Anything that sends people or requests back to your app needs the public URL instead of localhost. That includes OAuth callback URLs and webhook endpoints. The guides for OAuth callbacks and webhook testing walk through it.
Free or Pro#
- Free: a random URL every time you connect, a time limit per connection and one server in Frankfurt. No credit card.
- Pro, $79 per user per year: a reserved subdomain with
--subdomain=my-app, your own domain with one CNAME record, no time limit, and servers on five continents.
A URL that stays the same matters for webhooks and OAuth. You register it once, instead of again after every restart. The plans are on the pricing section.
Share localhost on the same Wi-Fi, with a QR code#
You don't need a public URL to open the site on your phone, or to show it to someone in the room:
expose share http://localhost:3000 --lan --qr-code
Expose serves the site on your computer's network address, for example http://192.168.1.23:8080, and prints a QR code you can scan with your phone. Nothing goes through an Expose server, so you need no account and no internet connection. It uses port 8080 unless that port is taken. Use --lan=9000 to pick a port yourself.
LAN sharing has three limits:
- The connection is plain HTTP. Browsers only allow the camera, the clipboard and service workers on HTTPS pages, so those won't work on the other device. Use a normal tunnel when you need HTTPS.
- Everyone on the network can open it. On shared Wi-Fi, add a password, as in the next section.
- Your firewall has to let devices in. If they can't connect, allow incoming connections for
expose.
LAN sharing needs Expose 4.2 or later. See local network sharing.
Put a password or an email login in front of it#
Anyone who has a public URL can open it. Before you send one to a client, put a gate in front:
# A username and password (HTTP basic authentication)
expose share http://localhost:3000 --basicAuth="user:secret"
# A login page that asks for an email address
expose share http://localhost:3000 [email protected],[email protected]
Password protection makes the browser ask for the username and password. It doesn't work on a site that already uses basic authentication.
Magic authentication shows a login page instead, and lets in only the email domains and addresses you list. Visitors stay signed in for 7 days, or until you restart Expose. Expose doesn't email the address to confirm it, so magic authentication keeps out people who stumble on the URL. It won't stop someone who knows an accepted address. When that matters, pass both flags: visitors then need the password first and then an accepted address.
Option 2: port forwarding on your router#
Port forwarding is the do-it-yourself route. Your router passes connections that arrive on a public port to a computer on your network. It costs nothing and involves no third party. It does need three things a tunnel doesn't: access to the router, a public IPv4 address, and the time to secure what you open up.
The steps:
- Make the server listen on your network. A server bound to
127.0.0.1only accepts connections from your own machine. Bind it to0.0.0.0or to the computer's local address. - Give the computer a fixed local address. Set up a DHCP reservation in the router, so the forward doesn't point at a different device next week.
- Forward the port. In the router, forward an external port, such as 80 or 443, to that address and your server's port.
- Open the port in the firewall. Allow it in your computer's firewall.
- Test it from outside your network. For example, turn off Wi-Fi on your phone and open
http://YOUR-PUBLIC-IP.
Keeping it running takes more work:
- Your home IP can change. To keep a domain name pointing at it, you need a dynamic DNS service.
- HTTPS is your job. You get a certificate for that name and renew it.
- The open port is visible to the whole internet, scanners included. Your IP address is in the URL. A dev server with debug mode on was never meant to face that.
- Your ISP may block the port. If the forward looks right but nothing gets through, that may be why.
When port forwarding can't work: CGNAT#
Some ISPs use carrier-grade NAT (CGNAT). Your router then shares one public IPv4 address with other customers, and incoming connections stop at the ISP's NAT before they reach your router. No setting on your router can fix that.
The sign is a WAN address in 100.64.0.0/10 on your router's status page. The free CGNAT check tells you in a few seconds. If you are behind CGNAT, you have three ways out:
- ask your ISP for a public IPv4 address
- use IPv6, if your ISP gives you IPv6 addresses
- use an outbound tunnel, which CGNAT doesn't affect
Port forwarding or a tunnel?#
| Port forwarding | Tunnel | |
|---|---|---|
| Router access | Needed | Not needed |
| A public IPv4 address | Needed | Not needed |
| Behind CGNAT, or on someone else's network | Doesn't work | Works |
| HTTPS | You set it up | Included |
| Your home IP address | In the URL | Visitors reach the tunnel server |
| Open to the internet | Until you remove the rule | Only while the command runs |
Option 3: deploy it if it has to stay up#
A tunnel and port forwarding both serve the site from your computer. When you close the laptop, lose Wi-Fi or restart, the site goes offline. A dev server with debug output on is also not what you want real visitors to hit.
So be clear about what a tunnel is for. Expose is for development, demos and webhooks. It isn't a way to host a production site. If people are going to rely on the site, put it on a server:
- A static site (plain HTML, or the build of a React, Vue or Vite app) goes on a static host. Build it and upload the output folder.
- An app with a backend goes on a hosting platform for your stack, or on a server you rent and manage.
The tunnel stays useful after you deploy. Share your local branch to show a client a change before it goes live, or to debug a webhook against your local code.
Tunnel tools compared#
Several tools open a tunnel to localhost. Here is how the free versions differ:
| Tool | Share port 3000 | Free URL | Worth knowing |
|---|---|---|---|
| Expose | expose share http://localhost:3000 |
Random, new on each connection | Free account. No warning page. Request dashboard with replay. Time limit per connection on the free plan. |
| ngrok | ngrok http 3000 |
One dev domain that stays the same | Account and authtoken. Warning page in front of browser traffic on the free plan. 20,000 requests and 1 GB a month. |
| Cloudflare Quick Tunnels | cloudflared tunnel --url http://localhost:3000 |
Random trycloudflare.com, new each time | No account. Up to 200 in-flight requests, no Server-Sent Events. Cloudflare says they are "for testing and development". |
| Tailscale Funnel | tailscale funnel 3000 |
A name in your tailnet's ts.net domain | Needs Tailscale set up on the machine. In beta. Only ports 443, 8443 and 10000. |
| localtunnel | npx localtunnel --port 3000 |
Random | No account. Installed with npm. You can ask for a subdomain but may not get it. |
If you want a free URL that never changes, ngrok's free dev domain does that. Expose's free URL changes on every connection, and a fixed one comes with Pro.
We checked these details on November 16, 2026, in ngrok's free plan limits, Cloudflare's Quick Tunnels docs, Tailscale's Funnel docs and localtunnel's README. For paid plans, more tools and when each one fits better, see ngrok alternatives compared.
Questions#
Is it safe to expose localhost to the internet?#
With a tunnel, the internet can reach only the site or port you share, and only while the command runs. Visitors connect to the Expose server, not to your machine, so your IP address and your other ports stay hidden. Traffic is encrypted with TLS on every plan.
The risk is in what you share. Anyone with the URL can open it, so add --basicAuth or --magic-auth before you send it around. Don't share an app with real data while debug mode is on. Port forwarding is riskier: it leaves a port on your public IP open to everyone until you remove the rule.
Does my computer have to stay on?#
Yes, for a tunnel and for port forwarding alike. The site is served from your machine, so it goes offline when the computer sleeps, loses its connection, or stops the expose command. On the free plan, each connection also ends after a time limit. If the site has to be reachable all the time, deploy it to a server.
Can I use my own domain?#
Yes, with Expose Pro. Add the domain in your Expose dashboard and create the CNAME record it shows you. A subdomain such as share.example.com works well. Then share with it:
expose share http://localhost:3000 --domain=share.example.com
To use it every time without the flag, run expose default-domain share.example.com. DNS changes can take up to 48 hours to verify. If you only need a URL that stays the same, a reserved subdomain on an Expose domain needs no DNS at all. See custom domains.
Can I host localhost for free?#
For a demo, a test or a webhook, yes. The free plan needs no credit card and gives you a random HTTPS URL. Each connection has a time limit. For a site that stays online, port forwarding costs nothing if you have a public IPv4 address, but it comes with the security work described above. Otherwise you need a host.
How do I open localhost on my phone?#
If your phone is on the same Wi-Fi, run expose share http://localhost:3000 --lan --qr-code and scan the code. If it isn't, or the page needs HTTPS, share the site through a normal tunnel and open the public URL. The request dashboard at http://127.0.0.1:4040 shows a QR code for that URL too.