Sub topic 4
Enabling Dev Hub in Setup
This chapter assumes you can sign in to a Salesforce org as a system administrator, that you know your way around Setup, and that you understand what a scratch org and a Dev Hub are. Earlier chapters covered those ideas. Here you turn Dev Hub on in a real org, check that it worked, and learn the errors people hit most often.
What enabling Dev Hub does
Enabling Dev Hub is a one-time setting in Setup. It tells the org that it may create scratch orgs and track them. Once it is on, the org gets:
- The ability to authorize the Salesforce CLI against it as a Dev Hub.
- Records that track each scratch org you create, such as active scratch orgs and their expiry.
- Limits on how many scratch orgs can exist at once and how many can be created per day.
Enabling does not create any scratch org. It also does not change data or metadata that your users depend on. The change is small, but you cannot undo it, so be sure you are in the right org first.
Choose the right org first
Pick the org before you click anything. Teams usually use one of these:
| Org type | Good choice for a Dev Hub? | Notes |
|---|---|---|
| Production org | Yes, common in companies | Scratch orgs and their records are managed in one central place. |
| Developer Edition org | Yes, good for learning | Free and separate from company data. |
| Trial org | Yes, for short experiments | Trial orgs expire, so the Dev Hub goes away with them. |
| Sandbox | Not supported as a Dev Hub for normal use | Do not plan around it. |
| Scratch org | No | A scratch org cannot be a Dev Hub. |
Check Salesforce's current documentation for the full list of supported editions. Support can change by release, and trial orgs have extra conditions.
Permissions you need
To enable Dev Hub, you need to be an administrator of that org, in practice a user with the System Administrator profile or the equivalent permissions to change org-wide settings.
Enabling the feature and using it are separate things. A user who wants to create scratch orgs against the Dev Hub must also be able to sign in to it and have the right permissions. For most teams, that means one of two approaches:
- Give developers a profile or permission set that includes the Create and Delete Scratch Orgs and related Dev Hub permissions.
- Use the System Administrator profile for the Dev Hub users. This works but gives more access than they need.
Prefer the permission set approach in a shared company org. It follows least privilege and is easy to remove later.
Steps to enable Dev Hub
- Sign in to the org you chose.
- Click the gear icon, then Setup.
- In Quick Find, type
Dev Hub. - Select Dev Hub under Development.
- Turn on the Enable Dev Hub toggle.
- Read the warning that this cannot be undone, then confirm.
The page now shows the toggle as on. In some orgs, you will also see options for related features such as second-generation managed packaging. These are separate settings. Leave them alone unless you need them. This tutorial covers only the Dev Hub itself.
Verify that it worked
Open the Dev Hub page in Setup again. The toggle should be on and locked. If you can see it but cannot change it, that is the expected result after enabling.
The next chapter authorizes this org from the CLI. That step is a stronger test, because it proves the CLI can sign in and that the org is recognized as a Dev Hub. You can run it as soon as you finish here:
sf org login web --set-default-dev-hub --alias my-hubAfter you sign in, check the org list:
sf org listYour Dev Hub appears with an alias of my-hub and is marked as the default Dev Hub. If the login succeeds but the org is not marked as a Dev Hub, Dev Hub is probably not enabled in the org you signed in to. Compare the username you used with the org where you changed the setting.
Related setting: enabling in a new org
Some orgs, such as new Developer Edition sign-ups, can be created with Dev Hub already on. If the toggle is already on and cannot be changed, you have nothing to do. Skip to authorization.
If you manage many orgs, keep a short record of which one is your company's Dev Hub. Having two Dev Hubs for one team splits your scratch org limits and your tracking records across both. It also confuses new developers. Most teams settle on one Dev Hub per product or per company.
Common problems
The table lists errors and surprises that come up when enabling or first using Dev Hub. Your exact wording may differ by release.
| Symptom | Likely cause | What to do |
|---|---|---|
| No **Dev Hub** page in Quick Find | The org type does not support it, or you lack the permission | Check the edition. Ask an administrator. |
| Toggle is greyed out and already on | Dev Hub is already enabled | Continue to CLI authorization. |
| CLI login works but scratch org creation says the org is not a Dev Hub | You signed in to a different org than the one you enabled | Run `sf org list`, check usernames, and log in again to the right org. |
| A teammate cannot create scratch orgs | They are missing permissions in the Dev Hub | Add the permission set or profile access. |
| Plan to disable it later | Not possible | Use a separate throwaway org for testing next time. |
A note on production orgs
In a production org, a change to org-wide settings may fall under your company's change process. Enabling Dev Hub does not affect end users, but your security or release team may want to know. Tell them first, and record who enabled it and when. If they would rather keep production clean, use a separate Developer Edition org as the Dev Hub. That works for many teams, though it makes some features, such as certain packaging workflows, harder to set up. Check your needs before deciding.
Summary of decisions
- Pick a supported org that is stable and long-lived. A trial org is fine for learning, not for a team.
- Enable Dev Hub once, with an administrator account.
- Grant developers only the permissions they need.
- Verify by signing in from the CLI.
Exercise
You enabled Dev Hub in your company's production org by mistake while exploring Setup, and now you want to undo it. What can you do, and what should you do differently next time?
Show answer
You cannot disable Dev Hub once it is on, so the setting stays. It does no harm to users or data, but you should tell your admin or release team so it is recorded. Next time, practise in a Developer Edition or trial org, and confirm which org you are signed in to (check the username and the org name) before changing any org-wide setting.
Exercise
A developer signs in with sf org login web --set-default-dev-hub --alias my-hub and gets a successful login. Later, creating a scratch org fails because the org is not a Dev Hub. Name two likely causes and one command that helps you check.
Show answer
Likely causes: the developer signed in to a different org than the one where Dev Hub was enabled, or Dev Hub is not enabled in that org at all. A third possibility is that the user lacks Dev Hub permissions. Run sf org list to compare the username and alias with the org you enabled, then check the Dev Hub page in that org's Setup.