---
source: https://iinventedlight.com/library/notes/github-codespaces.md
title: "GitHub Codespaces: what happens when you create and stop one"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (github/docs); prose restates or closely paraphrases cited source lines"
license_family: github-docs-ccby
rule_check: "needs rule check (family not in auto-publish rule; check.mjs auto-approves only usgov and arxiv-ccby)"
attribution: "Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, What are GitHub Codespaces? - GitHub Docs, CC BY 4.0 (github/docs); GitHub Docs, Deep dive into GitHub Codespaces - GitHub Docs, CC BY 4.0 (github/docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: GitHub"
tags: ['github', 'codespaces', 'devcontainer']
sources:
  - id: S1
    title: "What are GitHub Codespaces? - GitHub Docs"
    publisher: GitHub Docs
    url: https://docs.github.com/en/codespaces/about-codespaces/what-are-codespaces
    accessed: 2026-11-04
    license: "CC BY 4.0 (github/docs)"
  - id: S2
    title: "Deep dive into GitHub Codespaces - GitHub Docs"
    publisher: GitHub Docs
    url: https://docs.github.com/en/codespaces/about-codespaces/deep-dive
    accessed: 2026-11-04
    license: "CC BY 4.0 (github/docs)"
---
# GitHub Codespaces: what happens when you create and stop one

**Answer:** You can connect to your codespaces from your browser, from Visual Studio Code, or by using GitHub CLI. When you connect, you are placed within the Docker container, with limited access to the outer Linux virtual machine host. (S1)

## Creating and setting up

- There are a number of entry points to create a codespace. (S2)
- Your codespace can be ephemeral if you need to test something, or you can return to the same codespace for long-running feature work. (S2)
- When you create a codespace, various steps happen in the background before the codespace is available to you. (S2)
- Once you are connected, your automated setup may continue to build based on the configuration in your devcontainer.json file, so you may see postCreateCommand and postAttachCommand run. (S2)
- If you want to use Git hooks in your codespace, set up hooks using the devcontainer.json lifecycle scripts, such as postCreateCommand. (S2)

## Saving, stopping and ports

- If you work on codespaces in Visual Studio Code, you can enable Auto Save to ensure that your changes are always saved. (S2)
- If a codespace times out it will stop running, but you can restart it from the browser tab, from within VS Code, or from your list of codespaces. (S2)
- When you close or stop your codespace, all uncommitted changes are preserved until you connect to the codespace again. (S2)
- Port forwarding gives you access to TCP ports running within your codespace. (S2)

## Claims
- id: C1
  claim: You connect to codespaces from a browser, VS Code, or GitHub CLI.
  source: S1
  evidence: "You can connect to your codespaces from your browser"
- id: C2
  claim: When you connect you are placed inside the Docker container.
  source: S1
  evidence: "When you connect, you are placed within the Docker container."
- id: C3
  claim: Uncommitted changes are preserved when a codespace is stopped.
  source: S2
  evidence: "all uncommitted changes are preserved until you connect to the codespace again."
- id: C4
  claim: Port forwarding exposes TCP ports running in the codespace.
  source: S2
  evidence: "Port forwarding gives you access to TCP ports running within your codespace."

## Sources
- [S1] What are GitHub Codespaces? - GitHub Docs. GitHub Docs. https://docs.github.com/en/codespaces/about-codespaces/what-are-codespaces . License: CC BY 4.0 (github/docs). Accessed 2026-11-04.
- [S2] Deep dive into GitHub Codespaces - GitHub Docs. GitHub Docs. https://docs.github.com/en/codespaces/about-codespaces/deep-dive . License: CC BY 4.0 (github/docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
