Overview
Microsoft devtunnel is a CLI tool that allows you to create secure tunnels to expose your local development services to the internet. This guide provides comprehensive setup instructions for installing and configuring devtunnel on Windows, macOS, and Linux.
Prerequisites
Before installing devtunnel, ensure you meet the following requirements:
System Requirements
Windows:
- Windows 10 (version 1809 or later) or Windows 11
wingetpackage manager (included in Windows 10/11) or PowerShell 5.1+- Administrator privileges (for some installation methods)
macOS:
- macOS 10.15 (Catalina) or later
- Homebrew (optional, for easier installation)
- Terminal access
Linux:
- Most modern Linux distributions (Ubuntu, Debian, Fedora, etc.)
- Bash shell
curlorwgetinstalled- Write permissions to
/usr/local/binor user’s local bin directory
Account Requirements
- Microsoft Account or Azure AD account: Required for authenticated tunnels (recommended)
- Internet connection: Required for tunnel creation and management
Quick Windows
| |
Installation
Windows
Method 1: Using winget (Recommended)
The easiest way to install devtunnel on Windows is using the Windows Package Manager:
| |
After installation, verify it’s working:
| |
Method 2: Using PowerShell Script
If winget is not available, you can use the PowerShell installation script:
| |
Method 3: Direct Download
- Visit the Microsoft devtunnel releases page
- Download the Windows executable (
.exe) for your architecture (x64, ARM64) - Extract the executable to a directory in your PATH (e.g.,
C:\Program Files\devtunnel\) - Add the directory to your system PATH environment variable if needed
Verification (Windows)
After installation, verify the installation:
| |
Expected output:
| |
If the command is not recognized:
- Restart your terminal/command prompt
- Verify the installation path is in your system PATH
- Try using the full path to the executable
macOS
Method 1: Using Homebrew (Recommended)
If you have Homebrew installed:
| |
After installation, verify:
| |
Method 2: Using Installation Script
Run the official installation script:
| |
This script will:
- Download the appropriate binary for your Mac architecture
- Install it to
/usr/local/bin/devtunnel - Make it executable
Method 3: Manual Installation
- Visit the Microsoft devtunnel releases page
- Download the macOS binary for your architecture (Intel or Apple Silicon)
- Extract the binary
- Move it to a directory in your PATH:
| |
Verification (macOS)
Verify the installation:
| |
If you get a “command not found” error:
- Check that
/usr/local/binis in your PATH:echo $PATH - Add it if needed:
export PATH=$PATH:/usr/local/bin - Restart your terminal
Linux
Method 1: Using Installation Script (Recommended)
Run the official installation script:
| |
This will install devtunnel to /usr/local/bin/devtunnel.
Method 2: Manual Installation
- Visit the Microsoft devtunnel releases page
- Download the Linux binary for your architecture (x64, ARM64, etc.)
- Extract and install:
| |
Method 3: Using Package Managers
Some Linux distributions may have devtunnel in their repositories. Check your distribution’s package manager:
For Debian/Ubuntu:
| |
For Fedora/RHEL:
| |
Verification (Linux)
Verify the installation:
| |
If the command is not found:
- Check PATH:
echo $PATH - Verify the binary exists:
ls -la /usr/local/bin/devtunnel - Add to PATH if needed:
export PATH=$PATH:/usr/local/bin
Verification
After installation on any platform, perform these verification steps:
1. Check Version
| |
This confirms the installation and shows the installed version.
2. Check Help
| |
This displays available commands and confirms the CLI is functional.
3. Verify Authentication Status
| |
This shows your current authentication status (will prompt login if not authenticated).
Common Verification Issues
Command not found:
- Restart your terminal
- Verify PATH includes the installation directory
- Use full path to executable
Permission denied (Linux/macOS):
- Ensure the binary is executable:
chmod +x /usr/local/bin/devtunnel - Use
sudoif installing to system directories
- Ensure the binary is executable:
Version check fails:
- Reinstall using the recommended method for your platform
- Check for network connectivity issues
Authentication
Authentication is required for most devtunnel operations, especially for private tunnels. Here’s how to set it up:
Initial Login
Run the login command:
| |
This will:
- Open your default web browser
- Prompt you to sign in with your Microsoft account or Azure AD account
- Complete the authentication flow
- Store credentials locally for future use
Login Options
Interactive login (default):
| |
Login with specific account:
| |
This allows manual entry of authentication code if browser doesn’t open.
Verify Authentication
Check your authentication status:
| |
This displays:
- Your authenticated user account
- Account type (Microsoft Account or Azure AD)
- Authentication status
Logout
To sign out:
| |
This removes stored credentials. You’ll need to log in again for authenticated operations.
Authentication Notes
- Credentials are stored securely on your local machine
- Authentication persists across terminal sessions
- You may need to re-authenticate if credentials expire
- For anonymous/public tunnels, authentication is optional but not recommended for security
Basic Usage
Creating a Simple Tunnel
Expose a local service running on port 6001:
| |
This creates a private tunnel that requires authentication to access.
Creating a Public Tunnel
To create a tunnel accessible without authentication (use with caution):
| |
Flags explained:
-p 6001: Forwards local port 6001-a: Makes tunnel accessible without authentication (anonymous/public)
Tunnel Output
When a tunnel starts successfully, you’ll see output like:
| |
You can now access your local service via this public URL.
Stopping a Tunnel
Press Ctrl+C in the terminal where the tunnel is running.
Common Usage Examples
Expose a web application:
| |
Expose multiple ports:
| |
Create a named tunnel:
| |
Set tunnel protocol:
| |
Advanced Usage
Managing Tunnels
List all tunnels:
| |
Delete a tunnel:
| |
Show tunnel details:
| |
Tunnel Configuration
Set tunnel access:
| |
Configure port forwarding:
| |
Environment Variables
You can configure devtunnel using environment variables:
| |
Troubleshooting
Installation Issues
Windows
winget not found:
- Update Windows to the latest version
- Install winget manually from Microsoft Store
- Use alternative installation methods (PowerShell script or direct download)
Permission denied:
- Run terminal as Administrator
- Check antivirus software isn’t blocking installation
macOS
Homebrew not found:
- Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Use the installation script method instead
Binary not executable:
| |
Linux
Permission denied:
| |
Binary architecture mismatch:
- Download the correct binary for your CPU architecture
- Check architecture:
uname -m - Use x64 for 64-bit Intel/AMD, ARM64 for ARM processors
Authentication Issues
Login fails:
- Ensure you have an active internet connection
- Try logging out and logging back in:
devtunnel logoutthendevtunnel login - Clear browser cache and cookies
- Check if your organization requires specific Azure AD permissions
Browser doesn’t open:
- Use
--allow-no-browserflag:devtunnel login --allow-no-browser - Manually copy the authentication URL from terminal output
Authentication expired:
- Re-authenticate:
devtunnel login - Check system time is correct (authentication relies on accurate time)
Tunnel Creation Issues
No public endpoint printed:
- Verify your local service is running on the specified port
- Check firewall settings aren’t blocking connections
- Ensure you have internet connectivity
- Try a different port number
Port already in use:
- Find the process using the port:
- Windows:
netstat -ano | findstr :6001 - macOS/Linux:
lsof -i :6001ornetstat -tulpn | grep 6001
- Windows:
- Stop the conflicting process or use a different port
Connection refused:
- Verify your local service is listening on
localhostor127.0.0.1 - Check if your service binds to
0.0.0.0(all interfaces) - Ensure the service is actually running
Tunnel disconnects frequently:
- Check network stability
- Verify firewall/antivirus isn’t interfering
- Check for proxy settings that might affect connections
Platform-Specific Issues
Windows
Firewall blocking:
- Add devtunnel to Windows Firewall exceptions
- Allow inbound connections for the tunnel port
Antivirus interference:
- Add devtunnel to antivirus exclusions
- Temporarily disable to test if it’s the cause
macOS
Gatekeeper blocking:
| |
System Integrity Protection (SIP):
- If installing to protected directories, you may need to disable SIP (not recommended)
- Install to user directory instead:
~/bin/devtunnel
Linux
Missing dependencies:
- Install required libraries:
sudo apt-get install libssl-dev(Debian/Ubuntu) - Check distribution-specific requirements
SELinux blocking:
- Configure SELinux policies if needed
- Or set SELinux to permissive mode for testing (not recommended for production)
Security Best Practices
General Security
Use Authenticated Tunnels:
- Avoid using
-a(anonymous) flag unless absolutely necessary - Authenticated tunnels provide better access control
- Avoid using
Limit Tunnel Lifetime:
- Don’t leave tunnels running indefinitely
- Stop tunnels when not in use:
Ctrl+Cordevtunnel delete <tunnel-id>
Monitor Active Tunnels:
- Regularly check active tunnels:
devtunnel list - Delete unused or old tunnels
- Regularly check active tunnels:
Use HTTPS:
- Prefer HTTPS protocol for tunnels when available
- Ensures encrypted communication
Development vs Production
- Never use devtunnel for production services
- Devtunnel is designed for development and testing only
- Use proper hosting solutions (Azure App Service, AWS, etc.) for production
Access Control
- Private tunnels: Require Microsoft/Azure AD authentication
- Public tunnels: Accessible to anyone with the URL (use with extreme caution)
- Port restrictions: Only expose necessary ports
Data Protection
Don’t expose sensitive services:
- Databases with real data
- Services with authentication tokens
- Production APIs or services
Use test/development data only:
- Never use production credentials
- Use isolated test environments
Network Security
Firewall configuration:
- Ensure local firewall rules are appropriate
- Don’t disable security features
VPN considerations:
- Be aware of VPN routing that might affect tunnel connectivity
- Test tunnel behavior with VPN enabled/disabled
Credential Management
Secure authentication:
- Use strong Microsoft/Azure AD passwords
- Enable multi-factor authentication (MFA) on your account
- Don’t share authentication credentials
Logout when done:
- Use
devtunnel logouton shared machines - Clear credentials when switching accounts
- Use
Best Practices Summary
- ✅ Always use authenticated tunnels for private development
- ✅ Stop tunnels when not actively developing
- ✅ Regularly review and delete unused tunnels
- ✅ Never expose production services or sensitive data
- ✅ Use HTTPS when available
- ✅ Keep devtunnel CLI updated to latest version
- ✅ Monitor tunnel access and usage
- ❌ Don’t use public tunnels (
-a) for sensitive services - ❌ Don’t leave tunnels running unattended
- ❌ Don’t share tunnel URLs publicly without authentication