Note: Codespaces is currently in limited public beta and subject to change. During the beta period, GitHub does not make any guarantees about the availability of Codespaces. For more information about joining the beta, see "About Codespaces."
You can edit code, debug, and use Git commands while developing in a codespace with Visual Studio Code. For more information, see the Visual Studio Code documentation.
For the best experience with Codespaces, we recommend using a Chromium-based browser, like Google Chrome or Microsoft Edge. For more information, see "Troubleshooting your codespace."
Connecting to a codespace from Visual Studio Code
You can connect to your codespace directly from Visual Studio Code. For more information, see "Using Codespaces in Visual Studio Code."
Navigating to your codespace
- At the top of any page, click Codespaces.
- Click the name of the codespace you want to develop in.
Forwarding ports
Port forwarding gives you access to TCP ports running within your codespace. For example, if you're running a web application on port 3000, you can access the application from your browser to test and debug it.
When an application running inside a codespace outputs a port to the console, Codespaces detects the localhost URL pattern and automatically forwards those ports. You can click on the URL in the terminal to open it in a browser. For example, if an application outputs http://127.0.0.1:3000
or http://localhost:3000
to the console, the log would automatically convert the output to a clickable URL for port 3000.
Alternatively, you can also use any of the following ways to forward a port.
-
You can forward a port on demand by triggering the command palette (
shift command P
/shift control P
) and typing "Codespaces: Forward Port". You can then enter the number of the port you want to forward. -
You can automatically configure forwarded ports in a
.devcontainer.json
file using theforwardPorts
property. -
You can add or remove forwarded ports within the Remote Explorer extension. From the Remote Explorer you can copy and paste the URLs for forwarded ports, allowing you to access them through your browser.