Create and host a dev tunnel
Dev tunnels is a powerful tool to securely open your localhost to the internet and control who has access, so you can easily test and debug your web apps and webhooks from virtually anywhere. Create, host, and connect to your first dev tunnel in seconds.
In this quickstart, you'll learn how to create, host, and connect to your first dev tunnel in seconds.
Before you create a dev tunnel, you first need to download and install the
devtunnel CLI (Command Line Interface) tool that corresponds to your operating system.
Windows Package Manager (winget)
You can use winget, Microsoft's package manager for Windows, to install and update the
winget install Microsoft.devtunnel
This command installs the latest version by default and removes the older version in the same location, which is %LOCALAPPDATA%\Microsoft\WinGet\Packages. To specify a version, add
--version <version_number> with your desired version to the command.
winget upgrade Microsoft.devtunnel
You can also install the
devtunnel CLI using PowerShell and running the following command:
Invoke-WebRequest -Uri https://aka.ms/TunnelsCliDownload/win-x64 -OutFile devtunnel.exe .\devtunnel.exe -h
Direct download link:
Run commands with
devtunnel instead of
- Press the Windows key and type 'Environment variables'.
- Select the option 'Edit the system environment variables'.
- Select the 'Environment Variables...' button.
- There you see two tables, in the 'System Variables' table, find and select the 'PATH' variable.
- Select the 'Edit...' button.
- A window should pop up. Select the 'New' button.
- Type the directory path of your devtunnel.exe file (directory means exclude the file name from path.
- To find the directory string, you can navigate to the directory in PowerShell or terminal and type 'pwd')
- Select 'Ok' on all open windows and restart the command prompt.
To start a dev tunnel, you first need to log in with either a Microsoft Entra ID, Microsoft, or GitHub account. Dev tunnels doesn't support hosting tunnels anonymously for more information take a look at the CLI command reference documentation.
devtunnel user login
Once logged in you can start hosting a dev tunnel using the
host command. In the example below dev tunnels will:
- Run a local server on port
8080that echoes requests sent to it.
- Host a dev tunnel for the local port
8080that is accessible to the internet.
# Start a http server on port 8080 devtunnel echo http -p 8080 # Tunnel port 8080 devtunnel host -p 8080
host command prints something similar to the following example to the console.
Connecting to host tunnel relay wss://usw2-data.rel.tunnels.api.visualstudio.com/api/v1/Host/Connect/<tunnel_id> Hosting port 8080 at https://<tunnel_id>.usw2.devtunnels.ms:8080/, https://<tunnel_id>-8080.usw2.devtunnels.ms/ and inspect it at https:/<tunnel_id>-8080-inspect.usw2.devtunnels.ms/ Ready to accept connections for tunnel: <tunnel_id>
The printed text contains:
tunnel_id- The ID of the dev tunnel.
- Public URL - The URL, which can be used to access your dev tunnel,
https://<tunnel_id>.usw2.devtunnels.ms:8080/in this example.
- Inspect URL - The URL you can use to inspect the traffic sent across the dev tunnel in,
https:/<tunnel_id>-8080-inspect.usw2.devtunnels.ms/in this example.
To connect to the dev tunnel, you need to:
- Visit this URL in a web browser.
- Login using the same account as you used to host the dev tunnel. By default, dev tunnels are only accessible to you.
Congratulations! You can now access your local service across the internet.