Developing in a codespace

You can open a codespace on GitHub, then develop using Visual Studio Code's features.

Anyone can develop in a codespace owned by their user account.

Codespaces is available for user accounts using GitHub Free or GitHub Pro. For more information, see "GitHub's products."

In this article

Did this doc help you?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.

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."

  1. At the top of any page, click Codespaces.
    Codespaces link in header
  2. Click the name of the codespace you want to develop in.
    Name of codespace

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.

Automatic Port Forwarding

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.

    Command Palette Port Forwarding

  • You can automatically configure forwarded ports in a .devcontainer.json file using the forwardPorts 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.

    Remote Explorer Port Forwarding

Did this doc help you?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.