|
| 1 | +--- |
| 2 | +title: Restricting the idle timeout period |
| 3 | +shortTitle: Restrict timeout periods |
| 4 | +intro: 'You can set a maximum timeout period for any codespaces owned by your organization.' |
| 5 | +product: '{% data reusables.gated-features.codespaces %}' |
| 6 | +permissions: 'To manage timeout constraints for an organization''s codespaces, you must be an owner of the organization.' |
| 7 | +versions: |
| 8 | + fpt: '*' |
| 9 | + ghec: '*' |
| 10 | +type: how_to |
| 11 | +topics: |
| 12 | + - Codespaces |
| 13 | +--- |
| 14 | + |
| 15 | +## Overview |
| 16 | + |
| 17 | +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. |
| 18 | + |
| 19 | +The personal settings of a {% data variables.product.prodname_dotcom %} 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 Codespaces](/codespaces/customizing-your-codespace/setting-your-timeout-period-for-codespaces)." |
| 20 | + |
| 21 | +As an organization owner, you may want to configure constraints on the maximum idle timeout period for codespaces owned by your organization. This can help you limit costs associated with codespaces that are left to timeout after long periods of inactivity. You can set a maximum timeout for all codespaces owned by your organization, or for the codespaces of specific repositories. |
| 22 | + |
| 23 | +{% note %} |
| 24 | + |
| 25 | +**Note**: Maximum idle timeout constraints only apply to codespaces that are owned by your organization. |
| 26 | + |
| 27 | +{% endnote %} |
| 28 | + |
| 29 | +For more information about pricing for {% data variables.product.prodname_codespaces %} compute usage, see "[About billing for Codespaces](/billing/managing-billing-for-github-codespaces/about-billing-for-codespaces#codespaces-pricing)." |
| 30 | + |
| 31 | +### Behavior when you set a maximum idle timeout constraint |
| 32 | + |
| 33 | +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: |
| 34 | + |
| 35 | +> Idle timeout for this codespace is set to 60 minutes in compliance with your organization’s policy. |
| 36 | +
|
| 37 | +### Setting organization-wide and repository-specific policies |
| 38 | + |
| 39 | +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. |
| 40 | + |
| 41 | +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. |
| 42 | + |
| 43 | +## Adding a policy to set a maximum idle timeout period |
| 44 | + |
| 45 | +{% data reusables.profile.access_org %} |
| 46 | +{% data reusables.profile.org_settings %} |
| 47 | +{% data reusables.codespaces.codespaces-org-policies %} |
| 48 | +1. Click **Add constraint** and choose **Maximum idle timeout**. |
| 49 | + |
| 50 | +  |
| 51 | + |
| 52 | +1. Click {% octicon "pencil" aria-label="The edit icon" %} to edit the constraint. |
| 53 | + |
| 54 | +  |
| 55 | + |
| 56 | +1. Enter the maximum number of minutes codespaces can remain inactive before they time out, then click **Save**. |
| 57 | + |
| 58 | +  |
| 59 | + |
| 60 | +{% data reusables.codespaces.codespaces-policy-targets %} |
| 61 | +1. 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](/codespaces/managing-codespaces-for-your-organization/restricting-access-to-machine-types)" and "[Restricting the visibility of forwarded ports](/codespaces/managing-codespaces-for-your-organization/restricting-the-visibility-of-forwarded-ports)." |
| 62 | +1. After you have finished adding constraints to your policy, click **Save**. |
| 63 | + |
| 64 | +The policy will be applied to all new codespaces that are created, and to existing codespaces the next time they are started. |
| 65 | + |
| 66 | +## Editing a policy |
| 67 | + |
| 68 | +You can edit an existing policy. For example, you may want to add or remove constraints to or from a policy. |
| 69 | + |
| 70 | +1. Display the "Codespace policies" page. For more information, see "[Adding a policy to set a maximum idle timeout period](#adding-a-policy-to-set-a-maximum-idle-timeout-period)." |
| 71 | +1. Click the name of the policy you want to edit. |
| 72 | +1. Make the required changes then click **Save**. |
| 73 | + |
| 74 | +## Deleting a policy |
| 75 | + |
| 76 | +1. Display the "Codespace policies" page. For more information, see "[Adding a policy to set a maximum idle timeout period](#adding-a-policy-to-set-a-maximum-idle-timeout-period)." |
| 77 | +1. Click the delete button to the right of the policy you want to delete. |
| 78 | + |
| 79 | +  |
0 commit comments