Sub topic 13
Checking active and daily scratch org limits
This chapter assumes you have already authorized a Dev Hub with the alias my-hub and created at least one scratch org. You should be comfortable reading command output in a terminal.
Two limits, two different clocks
A Dev Hub enforces two separate scratch org limits.
| Limit | What it counts | How it frees up |
|---|---|---|
| Active scratch orgs | Scratch orgs that currently exist and have not expired | When an org is deleted or reaches its expiry date |
| Daily scratch orgs | Scratch orgs created in the last 24 hours | As creations age out of the 24-hour window |
The two limits behave differently when you clean up. Deleting a scratch org lowers your active count right away. It does not give back a daily creation, because the org was still created within the window.
The maximum values depend on the Dev Hub's edition and license. Don't rely on numbers from memory or from another team's org. Read them from your own Dev Hub.
Reading the limits from the CLI
The sf limits api display command lists API limits for an org. Point it at the Dev Hub, not at a scratch org.
sf limits api display --target-org my-hubThe output has one row per limit, with the remaining amount and the maximum. Find the two rows named ActiveScratchOrgs and DailyScratchOrgs. The values below are illustrative, and yours will differ.
Name Remaining Max
ActiveScratchOrgs 37 40
DailyScratchOrgs 78 80In this example, three scratch orgs are active and two were created in the past day. Remaining is the number you can still create before the limit blocks you.
Deciding what to do when you run low
Check the limits before a burst of creation, such as a CI run that makes one scratch org per pull request. The two limits call for different actions.
If the active limit is the problem, delete orgs you no longer need:
sf org delete scratch --target-org my-scratch --no-promptYou can also list your orgs with sf org list to find old scratch orgs. Orgs that have passed their expiry date are marked as expired in that list.
Common mistakes
- Running
sf limits api displayagainst a scratch org alias. This shows that org's own API limits, not the Dev Hub's scratch org counts. - Forgetting that other people share the same Dev Hub. Your remaining count drops when teammates and pipelines create orgs.
- Setting long durations for throwaway orgs. A short
--duration-daysvalue releases the active slot sooner without any manual cleanup.
Exercise
Your sf limits api display --target-org my-hub output shows ActiveScratchOrgs remaining at 5 and DailyScratchOrgs remaining at 0. You delete three old scratch orgs. Can you create a new scratch org now, and why?
Show answer
No. Deleting the three orgs raises the active remaining count, but the daily limit still blocks creation. DailyScratchOrgs counts creations in the past 24 hours, and deleting an org does not remove it from that count. You must wait until older creations leave the 24-hour window.