Skip to main content

Stopping and starting a codespace

You can stop and start your codespace to save resources and to pause work.

Note

  • Using GitHub Codespaces with JetBrains IDEs is currently in public preview and is subject to change.
  • To work on a codespace in a JetBrains IDE you must use release 2023.3.* or 2024.1.* of the JetBrains Gateway.

About stopping and starting a codespace

You can stop a codespace at any time. When you stop a codespace, any running processes are stopped. Any saved changes in your codespace will still be available when you next start it. The terminal history is preserved, but the visible contents of the terminal window are not preserved between codespace sessions.

If you do not explicitly stop a codespace, it will continue to run until it times out from inactivity. Closing a codespace does not stop the codespace. For example, if you're using a codespace in the VS Code web client and you close the browser tab, the codespace remains running on the remote machine. For information about timeouts, see "Understanding the codespace lifecycle."

Only running codespaces incur CPU charges. A stopped codespace incurs only storage costs.

You may want to stop and restart a codespace to apply changes to it. For example, if you change the machine type used for your codespace, you will need to stop and restart it for the change to take effect. You can also stop your codespace and choose to restart or delete it if you encounter an error or something unexpected.

Regardless of where you created or access your codespaces, you can view and manage them in your browser at https://github.com/codespaces.

Stopping a codespace

  1. Navigate to the "Your Codespaces" page at https://github.com/codespaces.
  2. To the right of the codespace you want to stop, click the ellipsis (...).
  3. Click Stop codespace.

Screenshot of a list of codespaces with the dropdown menu for one of them displayed, showing the "Stop codespace" option.

To learn more about GitHub CLI, see "About GitHub CLI."

To stop a codespace use the gh codespace stop subcommand and then choose the codespace you want to stop from the list that's displayed.

Shell
gh codespace stop
  1. Open the VS Code Command Palette (Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux)).
  2. Type stop and select Codespaces: Stop Codespace from the list of options.
  3. In the list of codespaces, select the codespace you want to stop.

You can stop a codespace from the "Your codespaces" page (see the web browser instructions) or by using GitHub CLI (see the CLI instructions).

Restarting a codespace

  1. Navigate to the "Your Codespaces" page at https://github.com/codespaces.

  2. Click the name of the codespace you want to restart.

    Screenshot of a list of two codespaces on GitHub. The names of the codespaces are highlighted with dark orange outlines.

When you restart a codespace you can choose to open it in Visual Studio Code or in your browser.

  • To restart a codespace and open it in Visual Studio Code, use the gh codespace code subcommand and then choose the codespace you want to restart from the list that's displayed.

    Shell
    gh codespace code
    
  • To restart a codespace and open it in your browser, use the gh codespace open --web subcommand and then choose the codespace you want to restart from the list that's displayed.

    Shell
    gh codespace open --web
    
  1. Open the VS Code Command Palette (Shift+Command+P (Mac) / Ctrl+Shift+P (Windows/Linux)).
  2. Type connect and select Codespaces: Connect to Codespace from the list of options.
  3. In the list of codespaces, select the codespace you want to restart.

If you have set the JetBrains Gateway as your default editor, then the Gateway will launch automatically when you open a codespace from GitHub.

If the JetBrains Gateway is not your default editor, you can still open a codespace in JetBrains by going to the "Your codespaces" page at github.com/codespaces and clicking the ellipsis (...) to the right of the codespace you want to open. For more information, see "Opening an existing codespace."

Alternatively, you can also open the JetBrains Gateway and select an existing codespace, as described in the following procedure.

  1. Open the JetBrains Gateway application.

  2. Click Connect to Codespaces.

    Screenshot of the JetBrains Gateway home page, showing the "Connect to Codespaces" button.

  3. In the "Your Codespaces" list, click the codespace you want to work in.

    Screenshot of the "Your Codespaces" list in the JetBrains Gateway.

  4. In the "Available IDEs" list, click the JetBrains IDE you want to use. The Gateway will remember your choice the next time you connect to a codespace.

    Screenshot the "Select IDE" dropdown list in the JetBrains Gateway. The mouse pointer is pointing to "IntelliJ IDEA."

  5. Click Connect.

    Note

    • If you chose Rider as your JetBrains IDE and the repository contains multiple solution files, the "Set Solution Path" dialog is displayed prompting you to choose which solution you want to work in. Choose a solution file from the dropdown menu and click OK.

      If the repository doesn't have a solution file, Rider opens in a basic project directory view and will have limited capabilities. For instance, you won't get .NET-specific code navigation. If there is just a single solution file in the repository it will be used automatically, without the prompt being displayed. For more information, see "Create and open projects and solutions" in the JetBrains documentation.

    • If you are running a firewall, then the first time you connect to a remote resource you may be prompted to allow the JetBrains Gateway to communicate across your network.

Further reading