Skip to main content

How to Share a Local Web App with a Dev Tunnel

· 12 min read
Jagdish Kumawat
Founder @ Dewiride

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:

ResourceLimit
Bandwidth5 GB per user
Tunnels10 per user
Ports10 per tunnel
HTTP request rate1,500 per minute per port
Data transfer rateUp to 20 MB/s per tunnel

Syntax​

Syntax
devtunnel host -p <port> --allow-anonymous
PartWhat it is
devtunnel hostCreates 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-anonymousOptional. 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 devtunnel CLI. Microsoft's quickstart installs it with winget on Windows, Homebrew on macOS, or a script on Linux. Check it:

    Terminal
    devtunnel --version
    Output
    Tunnel CLI version: 1.0.2115+e16833f284

    Tunnel 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:

Terminal 1
devtunnel echo http -p 8080
Output
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.

Terminal 2
devtunnel user login -d
Output
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:

Microsoft's Enter code to allow access page, with a Code box and a Next button

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

Microsoft's Pick an account page: You're signing in to Dev Tunnels on another device located in India, with the account Leo Martin, leo.martin@example.com, signed in

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

Microsoft's Approve sign-in on another device page for leo.martin@example.com: You're signing in to Dev Tunnels using your example.com account, with the Approve and This wasn't me buttons

The browser confirms it:

Microsoft's Dev Tunnels page: You have signed in to the Dev Tunnels application on your device. You may now close this window.

And the terminal finishes:

Output
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.

Hosting before signing in

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:

Terminal 2
devtunnel host -p 8080 --allow-anonymous
Output
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. inc1 is the region the service picked, the one closest to me.

The command keeps running. The tunnel exists only as long as it does.

Who can connect

--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:

The dev tunnels warning page: You are about to connect to a developer tunnel at 9k5n9v0j-8080.inc1.devtunnels.ms, noting that the warning is shown once per tunnel and that the tunnel was created 26 seconds ago in inc1, with Continue and Report unsafe page buttons

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

The echo server's answer in the browser: the GET / request with Host localhost:8080, followed by headers the tunnel added, including X-Forwarded-Host 9k5n9v0j-8080.inc1.devtunnels.ms, X-Forwarded-Proto https and X-Forwarded-For with the visitor's address

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:

Terminal 3
curl https://9k5n9v0j-8080.inc1.devtunnels.ms/hello
Output
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:

The dev tunnel inspect page, a DevTools Network panel, listing one request: hello, status 200, type document, 387 B, 144 ms

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:

Terminal 3
devtunnel show neat-book-lt7dxtt.inc1
Output
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:

Terminal 3
devtunnel list
Output
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​

MistakeWhat happensDo this instead
Running devtunnel host before devtunnel user loginAnonymous does not have 'create' access scopeSign in first
Hosting a port nothing listens onThe tunnel opens, but requests through it failStart your app first and check it on localhost
Using --allow-anonymous for private workAnyone with the URL can reach your portLeave it out, so only you can connect
Saving a temporary tunnel's URL in a webhook or bot settingThe next devtunnel host -p gets a new URLUse a persistent tunnel, which keeps its URL

Troubleshooting​

SymptomLikely causeFix
Unauthorized tunnel creation access: Anonymous does not have 'create' access scopeThe CLI isn't signed inSign in with devtunnel user login
The browser asks you to sign inThe tunnel doesn't allow anonymous accessSign in with the hosting account, or host with --allow-anonymous
The inspect page stays emptyIt records only requests made while it's openKeep it open, then send the request
The Anonymous error comes back days laterThe cached sign-in expiredRun 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​