# How to expose localhost to the internet: a tunnel, or make it live?

You want someone else to open the app running on your laptop. Maybe a client wants a look, a payment service needs to send your app a message, or you want to try it on your phone.

There are two ways to do it, and they suit different jobs. A tunnel shares your laptop for an hour. Making the app live gives it a home of its own. Here's how to choose.

![A tunnel passes visitors through to your laptop, so the link stops working when the laptop sleeps. A live app runs on a computer that's always on, so the link keeps working.](/blog/images/tunnel-vs-live.svg)

## What a tunnel does

A small program on your laptop connects out to a tunnel service. The service gives you a public link, and passes each visitor through that connection to your app.

Your app never leaves your laptop. The visitor is effectively using your computer.

Popular options include:

- **ngrok**, the best-known, with free and paid plans.
- **Cloudflare Tunnel**. Its quick tunnels give you a random link with no account, and Cloudflare describes them as for testing.
- **VS Code's port forwarding**, built into the editor. Links are private by default, and you can make them public.

Free plans and limits change often, so check the current terms of whichever you pick.

## When a tunnel is the right tool

- **Testing webhooks.** Payment services and other tools need a public address to send messages to, and you want them to reach the code you're editing.
- **A quick look.** "Here's where I've got to" on a call, for an hour.
- **Testing on your phone**, away from your Wi-Fi, or where you need `https`. We have a separate guide to [opening localhost on your phone](/blog/open-localhost-app-on-phone).

## Where a tunnel falls short

- **It stops when your laptop does.** Close the lid, lose Wi-Fi or restart, and the link goes dead.
- **The link often changes.** On many free plans, you get a new address every time you start the tunnel, so the one you shared yesterday stops working.
- **Visitors reach your development setup.** Development servers show detailed errors, and may run with test keys and settings. That's fine for you, but not for strangers.
- **It's as fast as your home internet.** Every visitor is served from your laptop, over your upload speed.
- **Some free plans show a warning page** before visitors reach your app.

## What making it live means

Your app gets copied to a computer that's always on, and runs there. That's what people call deploying it. Your laptop is free to sleep, the link stays the same, and visitors get the finished app instead of your work in progress.

It also means the app needs its own versions of what it used on your laptop: a database, somewhere to keep uploads and its secret keys. The [localhost to live guide](/blog/deploy-app-from-localhost) walks through what that involves.

## Side by side

| | Tunnel | Live app |
|---|---|---|
| Works with your laptop closed | No | Yes |
| Link stays the same | Often not, on free plans | Yes |
| Visitors see | Your development version | The finished app |
| Speed | Your home internet | A server's connection |
| Good for | Webhooks, quick demos, testing | Anything people will keep using |

## Doing it with Toupas

If you've decided it's time to make the app live, paste this into your coding agent:

```
Make this app live with Toupas. Instructions: https://toupas.com/agents.md
```

You get a link like `yourapp.toupas.app`, and your app gets a database and file storage if it needs them. Every new app is free for 30 days, with no card. Keep using a tunnel for webhook tests while you work, if you like: the two don't clash.

## Questions

### How do I make localhost accessible from the internet?

Run a tunnel, such as ngrok or Cloudflare Tunnel, to get a temporary public link to your laptop. For a link that keeps working when your laptop is off, deploy the app to a host.

### Is it safe to expose localhost to the internet?

For a short test, usually, but anyone with the link can reach your development server, including its detailed error pages. Don't leave it open, and don't use real secret keys in development.

### Why does my tunnel link stop working?

The tunnel only works while your laptop, the tunnel program and your app are all running. Many free plans also give you a new link each time you restart.

### Should I use a tunnel or deploy my app?

Use a tunnel for testing, webhooks and quick demos. Deploy when other people will use the app, or you want the link to keep working.
