Skip to main content

Restricting the idle timeout period

You can set a maximum timeout period for any codespaces owned by your organization.

Who can use this feature

To manage timeout constraints for an organization's codespaces, you must be an owner of the organization.

Os GitHub Codespaces estão disponíveis para organizações que usam o GitHub Team ou o GitHub Enterprise Cloud. GitHub Codespaces também está disponível como uma versão beta limitado para usuários individuais nos planos GitHub Free e GitHub Pro. Para obter mais informações, confira "produtos de GitHub".

Overview

By default, codespaces time out after 30 minutes of inactivity. When a codespace times out it is stopped and will no longer incur charges for compute usage.

The personal settings of a GitHub user allow them to define their own timeout period for codespaces they create. This may be longer than the default 30-minute period. For more information, see "Setting your timeout period for GitHub Codespaces."

As an organization owner, you may want to configure constraints on the maximum idle timeout period for codespaces created for repositories owned by your organization. This can help you to limit costs associated with codespaces that are left to timeout after long periods of inactivity. You can set a maximum timeout for the codespaces for all repositories owned by your organization, or for the codespaces of specific repositories.

Note: Maximum idle timeout constraints only apply to codespaces that are owned by your organization.

For more information about pricing for GitHub Codespaces compute usage, see "About billing for GitHub Codespaces."

Behavior when you set a maximum idle timeout constraint

If someone sets the default idle timeout to 90 minutes in their personal settings and they then start a codespace for a repository with a maximum idle timeout constraint of 60 minutes, the codespace will time out after 60 minutes of inactivity. When codespace creation completes, a message explaining this will be displayed:

Idle timeout for this codespace is set to 60 minutes in compliance with your organization’s policy.

Setting organization-wide and repository-specific policies

When you create a policy, you choose whether it applies to all repositories in your organization, or only to specified repositories. If you create an organization-wide policy with a timeout constraint, then the timeout constraints in any policies that are targeted at specific repositories must fall within the restriction configured for the entire organization. The shortest timeout period - in an organization-wide policy, a policy targeted at specified repositories, or in someone's personal settings - is applied.

If you add an organization-wide policy with a timeout constraint, you should set the timeout to the longest acceptable period. You can then add separate policies that set the maximum timeout to a shorter period for specific repositories in your organization.

Note: Organization policies you define for Codespaces only apply to codespaces for which your organization will be billed. If an individual user creates a codespace for a repository in your organization, and the organization is not billed, then the codespace will not be bound by these policies. For information on how to choose who can create codespaces that are billed to your organization, see "Enabling GitHub Codespaces for your organization."

Adding a policy to set a maximum idle timeout period

  1. No canto superior direito do GitHub.com, clique na foto do seu perfil e clique em Suas organizações. Suas organizações no menu de perfil

  2. Ao lado da organização, clique em Configurações. Botão de configurações

  3. Na seção "Código, planejamento e automação" da barra lateral, selecione Codespaces e clique em Políticas.

  4. Na página "Políticas de codespace", clique em Criar Política.

  5. Insira um nome para sua nova política.

  6. Click Add constraint and choose Maximum idle timeout.

    Add a constraint for idle timeout

  7. Click to edit the constraint.

    Edit the timeout constraint

  8. Enter the maximum number of minutes codespaces can remain inactive before they time out, then click Save.

    Set the maximum timeout in minutes

  9. Na área "Alterar destino da política", clique no botão suspenso.

  10. Escolha Todos os repositórios ou Repositórios selecionados para determinar a quais repositórios essa política se aplicará.

  11. Se você escolheu Repositórios selecionados:

    1. Clique em .

      Editar as configurações da política

    2. Selecione os repositórios aos quais você quer que esta política seja aplicada.

    3. Na parte inferior da lista de repositórios, clique em Selecionar repositórios.

      Selecionar repositórios para esta política

  12. If you want to add another constraint to the policy, click Add constraint and choose another constraint. For information about other constraints, see "Restricting access to machine types," "Restricting the visibility of forwarded ports," and "Restricting the retention period for codespaces."

  13. After you've finished adding constraints to your policy, click Save.

The policy will be applied to all new codespaces that are created, and to existing codespaces the next time they are started.

Editing a policy

You can edit an existing policy. For example, you may want to add or remove constraints to or from a policy.

  1. Display the "Codespace policies" page. For more information, see "Adding a policy to set a maximum idle timeout period."
  2. Click the name of the policy you want to edit.
  3. Make the required changes then click Save.

Deleting a policy

  1. Display the "Codespace policies" page. For more information, see "Adding a policy to set a maximum idle timeout period."

  2. Click the delete button to the right of the policy you want to delete.

    The delete button for a policy