I'm doing one of the Salesforce DX trailheads and am running into an issue where the error message is, "The scratch org does not belong to the dev hub username" when creating a password for a scratch org. Any tips?

  • why do you need to create a password for a scratch org, the password is cached by the cli tool in your workstation. instead use the sfdx command to open – OK999 Nov 15 '17 at 18:18
  • it's part of the trailhead steps – nhelterbrand Nov 15 '17 at 19:52

Did you login into your DevHub instance before trying to generate password with this command?

sfdx force:auth:web:login -d -a DevHub

If you did not specify the -d flag, or you did use the -d flag on a different org during creating it, you wont be able to create scratch orgs until you correctly identify the Dev Hub using the config:set command, for example:

force:config:set defaultusername=me@my.org defaultdevhubusername=me@myhub.org

If everything is ok and there is a (D) next to your DevHub org when you run

sfdx force:org:list

you should be able to execute these commands

sfdx force:org:create -f config/project-scratch-def.json -a YourScratch
sfdx force:user:password:generate -u YourScratch
sfdx force:org:display -u YourScratch

and should see the new password in the detail. Hope this helps.

  • I ended up having to delete the scratch org. Then I logged into my DevHub instance and created the scratch org afterwards which allowed me to create a password without the error I was getting before. Thanks! – nhelterbrand Nov 17 '17 at 21:08

the key here might be to look into the details. execute this, to check if you are using the right devHub account

$ sfdx force:org:display -u <alias_name_scratch_org>

look for the Dev Hub Id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.