Overview
VS Code Remote Tunnels enable you to securely connect to a remote machine and access VS Code through your browser via vscode.dev from anywhere, without requiring SSH or complex networking configuration.Remote Tunnels create a persistent connection between your machine and Microsoft’s tunnel service, allowing browser-based access to your development environment.
How It Works
The tunnel feature:- Creates a secure tunnel from your machine to Microsoft’s tunnel service
- Generates a unique URL accessible via vscode.dev
- Allows you to code in your browser while commands execute on the remote machine
- Maintains file synchronization and extension compatibility
Getting Started
Starting a Tunnel
The simplest way to start a tunnel:- Prompt you to log in with GitHub or Microsoft account
- Accept the server license terms (or use
--accept-server-license-termsto skip) - Create a tunnel with an auto-generated machine name
- Display the vscode.dev URL for access
Tunnel Commands
tunnel (serve)
Start a tunnel (default subcommand):Options
Set a custom machine name for the tunnel
Use a randomly generated machine name
Prevent the machine from going to sleep while tunnel is active
Accept server license terms without prompting
Directory where server data is kept
Directory for extensions
Pre-install extensions on the server
tunnel status
Check if a tunnel is currently running:tunnel kill
Stop any running tunnel on the system:tunnel restart
Restart the running tunnel:tunnel rename
Change the machine name associated with the tunnel:Renaming requires an active tunnel or previous registration.
tunnel unregister
Remove this machine’s association with the tunnel service:tunnel prune
Delete all server data for tunnels that are no longer running:User Management
tunnel user login
Log in to the tunnel service:Options
Authentication provider to use
Access token for authentication (also via
VSCODE_CLI_ACCESS_TOKEN env var)Refresh token for authentication (also via
VSCODE_CLI_REFRESH_TOKEN env var)tunnel user logout
Log out from the tunnel service:tunnel user show
Display the currently logged-in account:Running as a Service
For production or always-on scenarios, run the tunnel as a system service.tunnel service install
Install the tunnel as a system service:- Starts automatically on boot
- Restarts on failure
- Runs in the background
- Persists across reboots
Options
Accept license terms without prompting
Machine name for the tunnel
tunnel service uninstall
Remove the tunnel service:tunnel service log
View logs from the tunnel service:Service management requires administrative privileges (sudo on Linux/macOS, Administrator on Windows).
Setup and Configuration
Initial Setup
Automated Setup
For headless servers or CI/CD environments:Configuration Files
The tunnel stores configuration in:- Linux/macOS:
~/.vscode-cli/ - Windows:
%USERPROFILE%\.vscode-cli\
--cli-data-dir:
Connection and Usage
Accessing Your Tunnel
Once a tunnel is running, access it via:- Direct URL:
https://vscode.dev/tunnel/<machine-name> - vscode.dev: Go to vscode.dev → Remote Explorer → Select your machine
- Desktop VS Code: Use Remote-Tunnels extension
Working with Files
The browser interface provides full VS Code functionality:- File explorer with remote file system
- Integrated terminal running on remote machine
- Extension marketplace (extensions run remotely)
- Source control integration
- Debugging support
Multiple Tunnels
You can run tunnels on multiple machines:Security Considerations
Authentication
Tunnels require authentication via:- GitHub account
- Microsoft account
- Access tokens (for automation)
Connection Security
The tunnel connection:- Uses TLS encryption
- Routes through Microsoft’s secure tunnel service
- Validates authentication on each connection
- Supports token-based access control
Best Practices
Secure Token Storage
Secure Token Storage
When using access tokens for automation:
Network Isolation
Network Isolation
The tunnel only exposes VS Code’s development interface. It does NOT:
- Open arbitrary ports
- Expose your entire file system
- Allow direct shell access (only via VS Code’s integrated terminal)
Service Hardening
Service Hardening
When running as a service:
Audit and Monitoring
Audit and Monitoring
Monitor tunnel usage:
Firewall Requirements
Tunnels require outbound HTTPS (443) access to:global.rel.tunnels.api.visualstudio.com*.tunnels.api.visualstudio.com
Advanced Usage
Port Forwarding
Tunnels automatically support port forwarding. When your app listens on a port:Custom Server Arguments
Configure the remote server:Reconnection Grace Period
The tunnel maintains sessions even if connection drops:Integration with CI/CD
Troubleshooting
Tunnel Won’t Start
Authentication Issues
Authentication Issues
Port Conflicts
Port Conflicts
Check if another tunnel is running:
Network Issues
Network Issues
Verify connectivity to tunnel service:Check firewall allows outbound HTTPS.
Service Issues
Service Won't Start
Service Won't Start
Check service logs:
Permission Errors
Permission Errors
Ensure service has necessary permissions:
Performance Optimization
Comparison with Other Remote Solutions
| Feature | Remote Tunnels | SSH + Remote-SSH | GitHub Codespaces |
|---|---|---|---|
| Setup Complexity | Low | Medium | Low |
| Browser Access | Yes | No | Yes |
| Firewall Config | None | Port forwarding | None |
| Cost | Free | Free | Paid |
| Machine Control | Full | Full | Limited |
| Network Required | Internet | Any | Internet |
Next Steps
CLI Commands
Explore all CLI commands and options
CLI Overview
Learn more about VS Code CLI basics
Extensions
Manage extensions for your tunnel
Web Server
Alternative: Run local web server