In GitHub Codespaces, why does a codespace stop on its own, and what does it still cost once stopped?
answer
- what counts as a user being present
- closing the tab is not stopping
- compute versus disk after the stop
- a clock that starts at the stop
basics
~20 sA codespace stops after an idle timeout: 30 minutes by default, settable from 5 to 240. Once stopped it no longer bills compute but keeps billing storage until deleted, which happens automatically after the retention period, 30 days by default.
solid answer
~50 sGitHub Codespaces bills compute only while a codespace is *active*, so an **idle timeout** stops it after a stretch with no sign of a user: no typing, no mouse, no terminal input or output. The default is 30 minutes; a user can set 5 to 240 minutes for new codespaces, or pass `--idle-timeout` to `gh codespace create`, and an organization policy can force a shorter maximum. Closing the browser tab does **not** stop it; it keeps running, and billing, until the timeout fires. A stopped codespace costs storage only, and that storage is billed until the codespace is deleted. Deletion is automatic after the **retention period** (default 30 days, allowed 0 to 30), counted from the stop, and it happens even if the codespace holds unpushed work. Separately, no codespace runs longer than 12 hours in one go: it is stopped at that point even while in use.
go deeper
Recall the two clocks: the idle timeout (30 minutes by default) stops a codespace, and the retention period (30 days by default) deletes a stopped one. Stopped still bills storage.
Explain what resets the idle timer, including terminal output, why closing the tab does not stop billing, and how the 0 to 30 day retention range and the 12-hour lifetime cap behave.
Show you would protect work and budget together: push before walking away, shorten idle timeouts, and explain to a team why a log-spewing server or a forgotten codespace still costs money.
Weigh short timeouts and retention against interrupted engineers and lost work, and decide which defaults a team should carry rather than leaving each person to discover them.
## Active, stopped, deleted A **codespace** is a cloud development environment: a dev container running on its own virtual machine, created from a repository. Over its life it moves through three states, and each one is billed differently: | State | What exists | What is billed | |---|---|---| | **Active** (running) | VM, container, disk | **Compute** for every hour it runs, plus **storage** | | **Stopped** | Disk only; processes are gone | **Storage** only | | **Deleted** | Nothing | Nothing from now on | The documentation says it plainly: only running codespaces incur CPU charges, and a stopped codespace incurs only storage costs. Two settings move a codespace along this line automatically: the **idle timeout** (active to stopped) and the **retention period** (stopped to deleted). A fixed 12-hour lifetime cap, described below, also stops it. ## The idle timeout The idle timeout exists because compute is billed for the time a codespace is active, whether anyone is using it or not. Its rules, as documented in October 2026: - **Default 30 minutes**, settable in personal Codespaces settings from **5 to 240 minutes**. A changed default applies to codespaces created afterwards. - `gh codespace create --idle-timeout 90m` sets the value for one new codespace. - An **organization policy** can set a *maximum* idle timeout for codespaces the organization pays for; when it is shorter than the user's own setting, the shorter value wins and the user is told so after creation. **Closing a codespace is not stopping it.** If you close the browser tab of the web editor, the codespace keeps running on the remote machine until the timeout fires. Stopping or deleting it explicitly is how compute billing ends before the timeout. ## What counts as activity "Inactivity" means the absence of activity that suggests a person is present. The timer is reset by: 1. typing or using the mouse in the editor; 2. **terminal input or output**, in either direction. The second point surprises people. A web server inside the codespace that prints a log line for every request keeps resetting the timer for as long as requests arrive, so a forgotten app that someone keeps polling may never go idle. Conversely, a shared port that receives traffic but writes nothing to a terminal does not keep the codespace alive. ## The 12-hour ceiling Independently of the idle timeout, a codespace has a **maximum lifetime of 12 hours**. As it approaches that limit the user is warned, the data is saved, and the codespace stops, even if someone is actively typing. Restarting it continues the work. This caps the damage of a codespace kept awake by terminal output. ## Stopped is not free: retention and deletion A stopped codespace keeps its disk: the repository clone, uncommitted changes, installed extensions, data the app wrote and, for a custom image, the container itself. That disk is billed as **storage** for as long as the codespace exists. The **retention period** bounds it: - **Default 30 days**, settable per user from **0 to 30 days**; `gh codespace create --retention-period` sets it for one codespace. An organization policy can impose a shorter maximum for codespaces it pays for, and the shortest applicable value wins. - The countdown starts when the codespace **stops**; a "day" is 24 hours from the time of the stop. Connecting to the codespace again resets it. - **Automatic deletion ignores unpushed changes.** Work that was never committed and pushed is gone with the codespace. - A value of **0** deletes a codespace the moment it stops or times out. - When the retention period is longer than a day, GitHub emails the owner one day before the deletion. - The **Keep codespace** option exempts one codespace from automatic deletion indefinitely; it is not available for organization-owned codespaces covered by an organization retention policy. Deleting a codespace stops further storage from accruing, but it does not lower the storage already counted in the current monthly billing cycle; that figure is cumulative. ## Habits that keep the bill honest - Stop a codespace when you finish rather than closing the tab. - Lower the idle timeout if you often walk away; 30 minutes is only a default. - Push work regularly, because retention deletes without asking about Git state. - Delete codespaces you will not return to instead of letting them sit out the retention period.
- A codespace runs a dev server that logs every request to the terminal. Why might it never hit its idle timeout?Terminal output counts as activity and resets the idle timer. While requests keep arriving and each one writes a log line, the codespace never looks idle and keeps billing compute. Short of an explicit stop, only the 12-hour maximum lifetime stops it, so stop it yourself or make sure nothing keeps calling a server you no longer need.
- How do you keep one stopped codespace past its retention period, and what does that cost?Reconnecting resets the retention countdown, which restarts at the next stop. To exempt it outright, use the Keep codespace option, which retains it until you delete it by hand; that option is unavailable for organization-owned codespaces under an organization retention policy. Either way the codespace keeps billing storage for as long as it exists.
- What happens when the retention period is set to 0 days?The codespace is deleted as soon as it stops, including when the idle timeout stops it. Anything not committed and pushed is lost. It suits throwaway codespaces, but it turns a coffee break past the idle timeout into lost work, so it needs the habit of pushing often.
A stopped codespace is a parked rental car: the engine is off, so no fuel is burned, but the parking meter (storage) keeps running until you hand the car back (delete it).
- Closing the browser tab stops the codespace and its billing.
- A stopped codespace costs nothing until someone starts it again.
- Automatic deletion skips a codespace that still holds unpushed commits.
- Only keyboard input counts as activity, so terminal output never delays the timeout.
- Deleting a codespace mid-month refunds the storage it already used that month.