Port Forwarding in VSCode

Accessing your localhost website from anywhere

1 July 2024

Port forwarding in Visual Studio Code
⚠️

Port forwarding may face security risks and are best recommended only for ad-hoc testing and development.

Visual Studio Code has a built-in support for port forwarding via Microsoft Dev Tunnels (does not require downloading extensions), which can make the service accessible to other people over the internet. By default, tunnels are private and only accessible to the creator (requires sign-in with the associated Github account), but can be changed to public.

Using Port Forwarding

Forwarding a port
  1. Run a service in the local machine
  2. Navigate to the Ports view in the Panel
  3. Select Forward a Port, and enter the port (i.e. 3000)
  4. Wait for port forwarding system to start and the Ports view will show the forwarded address
ℹ️

Sign in to Github is required if you have not logged in