How to Share a Local Web App with a Dev Tunnel
A dev tunnel gives a port on your computer a public HTTPS address, so a phone, a colleague or a cloud service can reach an app that runs only on your machine. One command creates it, and Ctrl+C deletes it again.
Dev tunnels are a Microsoft service with a command-line tool, devtunnel. Microsoft describes them as being for adhoc testing and development, not for production workloads: showing work in progress, testing a site on your phone, or receiving webhooks and bot messages while the code still runs locally. The service is in public preview, and Microsoft's documentation says the CLI's command names and options may still change.
Cost: you need no Azure subscription or payment method, only a sign-in with a Microsoft, Microsoft Entra ID or GitHub account. Use is capped by limits per user instead, which reset every month:
| Resource | Limit |
|---|---|
| Bandwidth | 5 GB per user |
| Tunnels | 10 per user |
| Ports | 10 per tunnel |
| HTTP request rate | 1,500 per minute per port |
| Data transfer rate | Up to 20 MB/s per tunnel |
Syntax
devtunnel host -p <port> --allow-anonymous
| Part | What it is |
|---|---|
devtunnel host | Creates a tunnel and keeps it open while the command runs. Without a tunnel ID, it creates a temporary tunnel, which is deleted when you stop the command |
-p <port> | The port on your computer that the tunnel forwards to, such as 8080 |
--allow-anonymous | Optional. Lets anyone who has the URL connect. Without it, only you can, after signing in in the browser |
Before you can host a tunnel, you sign in once with devtunnel user login.
The Example
The devtunnel CLI has a tiny web server built in: devtunnel echo http -p 8080 answers every request with the request it received. That makes it a handy first app to share, because it shows exactly what arrives through the tunnel, and you don't need to write any code. Any app on any port works the same way: your website, your API or your bot.
Prerequisites
-
The
devtunnelCLI. Microsoft's quickstart installs it withwingeton Windows, Homebrew on macOS, or a script on Linux. Check it:Terminaldevtunnel --versionOutputTunnel CLI version: 1.0.2115+e16833f284Tunnel service URI : https://global.rel.tunnels.api.visualstudio.com/Tunnel service version : 1.0.2165.24615 (602779136d; 2026-11-09 18:17:43Z)Tunnel service cluster : inc1 -
A Microsoft, Microsoft Entra ID (work or school) or GitHub account to sign in with.
Step 1: Start a Local Web Server
Open a terminal and start the echo server on port 8080:
devtunnel echo http -p 8080
Echo server listening at http://127.0.0.1:8080/ (ws://127.0.0.1:8080/)
It keeps running and answers on http://127.0.0.1:8080/, but only on your computer. Leave this terminal open.
Step 2: Sign In to Dev Tunnels
Microsoft's quickstart is clear about this step: Dev tunnels doesn't support hosting tunnels anonymously. Open a second terminal and sign in. -d uses a device code: the CLI prints a code, and you type it into any browser. Leave -d out and the CLI opens your browser for you; add -g to sign in with GitHub.
devtunnel user login -d
To sign in, use a web browser to open the page https://login.microsoft.com/device and enter the code A1B2C3D4E to authenticate.
Open https://login.microsoft.com/device, type the code from your terminal and select Next:

Pick the account to sign in with. The page names the app: Dev Tunnels.

Check that you started this sign-in yourself, then select Approve:

The browser confirms it:

And the terminal finishes:
Logged in as user@example.com using Microsoft.
The CLI keeps the sign-in in your system's secure key store, and according to Microsoft's CLI reference it stays valid for several days before expiration. You don't need to sign in again every time.
If you run devtunnel host first, it fails with Unauthorized tunnel creation access: Anonymous does not have 'create' access scope. Fixed: "Unauthorized tunnel creation access: Anonymous does not have 'create' access scope for The default tunnel domain" walks through it.
Step 3: Host the Port
In the same terminal, host port 8080, open to anyone with the link:
devtunnel host -p 8080 --allow-anonymous
Connection to host tunnel relay restored.
Hosting port: 8080
Connect via browser: https://9k5n9v0j.inc1.devtunnels.ms:8080, https://9k5n9v0j-8080.inc1.devtunnels.ms
Inspect network activity: https://9k5n9v0j-8080-inspect.inc1.devtunnels.ms
Ready to accept connections for tunnel: neat-book-lt7dxtt.inc1
Each line tells you something:
- Connect via browser gives two public addresses for the same port. The second,
https://<id>-8080.<region>.devtunnels.ms, is the one most tools expect, because it uses the normal HTTPS port. - Inspect network activity is a page where you can watch the requests that go through the tunnel. Step 5 uses it.
- Ready to accept connections names the tunnel:
neat-book-lt7dxtt.inc1.inc1is the region the service picked, the one closest to me.
The command keeps running. The tunnel exists only as long as it does.
--allow-anonymous lets anyone who has the URL reach your port. Microsoft's CLI reference warns that anyone on the internet is able to connect to your local server, if they can guess the dev tunnel ID. Share only something that's safe to share, and leave the option out when only you need to connect: then the browser asks you to sign in with the account that hosts the tunnel.
Step 4: Open the URL in a Browser
Open the second Connect via browser address. The first time a browser visits a tunnel, the service shows a warning page first:

It protects visitors from phishing pages hosted on tunnels. Select Continue, and the echo server answers with the request your browser sent:

This shows what your app receives through a tunnel. The service ends HTTPS at its edge and passes the request on to your port, so Host says localhost:8080. The original address is in X-Forwarded-Host, the original scheme in X-Forwarded-Proto: https, and the visitor's IP address in X-Forwarded-For (masked here). An app that builds links or redirects from the request needs those headers.
Step 5: Watch the Traffic
Open the Inspect network activity address in your browser. It's a browser DevTools Network panel for your tunnel. It records the requests that arrive while it's open, so keep it open and send one from a third terminal. curl is a command-line HTTP client:
curl https://9k5n9v0j-8080.inc1.devtunnels.ms/hello
GET /hello HTTP/1.1
Accept: */*
Host: localhost:8080
User-Agent: curl/8.7.1
X-Request-ID: 00000000000000000000000000000000
X-Real-IP: 203.0.113.10
X-Forwarded-Port: 443
X-Forwarded-Scheme: https
X-Original-URI: /hello
X-Scheme: https
X-Forwarded-Proto: https
X-Forwarded-Host: 9k5n9v0j-8080.inc1.devtunnels.ms
X-Forwarded-For: 203.0.113.10
Proxy-Connection: Keep-Alive
curl got the echo straight away, without the warning page: Microsoft's security documentation says the page is skipped when a request's Accept header doesn't contain text/html, which is the case for curl, webhooks and bots. The request also shows up in the inspect page:

Select a request there to see its headers and response, as in your browser's own DevTools.
Step 6: Check the Tunnel's Settings
devtunnel show prints a tunnel's details:
devtunnel show neat-book-lt7dxtt.inc1
Tunnel ID : neat-book-lt7dxtt.inc1
Description :
Labels :
Access control : {+Anonymous [connect]}
Host connections : 1
Client connections : 0
Current upload rate : 0 MB/s (limit: 20 MB/s)
Current download rate : 0 MB/s (limit: 20 MB/s)
Ports : 1
8080 auto https://9k5n9v0j-8080.inc1.devtunnels.ms/
Tunnel Expiration : 30 days
{+Anonymous [connect]} is what --allow-anonymous added: anonymous visitors may connect. Host connections: 1 is your devtunnel host command, and auto means the service detects whether the port speaks HTTP or HTTPS.
Step 7: Stop Sharing
Press Ctrl+C in Terminal 2. Because the tunnel was temporary, stopping the host deletes it. Microsoft's CLI reference: If an existing dev tunnel wasn't provided, the dev tunnel that was automatically created by the process will be deleted on process exit. Check:
devtunnel list
No tunnels found.
The URL stops working, and the next devtunnel host -p 8080 gets a new one. Press Ctrl+C in Terminal 1 to stop the echo server too. You stay signed in to the CLI; run devtunnel user logout if you want to clear the sign-in.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Running devtunnel host before devtunnel user login | Anonymous does not have 'create' access scope | Sign in first |
| Hosting a port nothing listens on | The tunnel opens, but requests through it fail | Start your app first and check it on localhost |
Using --allow-anonymous for private work | Anyone with the URL can reach your port | Leave it out, so only you can connect |
| Saving a temporary tunnel's URL in a webhook or bot setting | The next devtunnel host -p gets a new URL | Use a persistent tunnel, which keeps its URL |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Unauthorized tunnel creation access: Anonymous does not have 'create' access scope | The CLI isn't signed in | Sign in with devtunnel user login |
| The browser asks you to sign in | The tunnel doesn't allow anonymous access | Sign in with the hosting account, or host with --allow-anonymous |
| The inspect page stays empty | It records only requests made while it's open | Keep it open, then send the request |
| The Anonymous error comes back days later | The cached sign-in expired | Run devtunnel user login again |
FAQ
Does the URL stay the same?
Not for a temporary tunnel: each devtunnel host -p creates a new tunnel with a new ID. When a service needs a fixed address, such as a bot's messaging endpoint, create a dev tunnel that keeps its URL.
Can I share more than one port?
Yes. Microsoft's CLI reference shows devtunnel host -p 3000 5000, which hosts two ports in one temporary tunnel.
Is the connection encrypted?
Between the visitor and the service, yes. Microsoft's security documentation says plain HTTP connections are always automatically upgraded to HTTPS, and TLS ends at the service's edge. Your local app keeps listening on plain HTTP, as the echo server did.
Conclusion
Sign in once with devtunnel user login, run devtunnel host -p <port> (add --allow-anonymous when the link should work for anyone), and your local app has a public HTTPS address. The inspect page shows what comes through, and Ctrl+C deletes the tunnel again.
Additional Resources
- Create and host a dev tunnel — Microsoft's quickstart, with the install commands.
- Dev tunnels command-line reference — every command and option.
- Dev tunnels security — the warning page, HTTPS and access control.
- Dev tunnels limits — the monthly limits.
