I was trying to create a scratch org following the trailhead


I'm stuck in the following section Create and Test Our Scratch Org - Step 2

while executing the following command getting the following error.

sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org

ERROR running force:org:create: Must pass a username and/or OAuth options when creating an AuthInfo instance.

Steps Executed

  1. Created Project in VSCode
  2. Authorized an Org
  3. Executed Trailhead steps as mentioned in the link

4 Answers 4


You have to login first.

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

(This is in the prior step, you can't work on them separately.)


Authorize your Dev Hub on the same folder directory where you will create your scratch org.

\VSCodeQuickstart\my_sfdx_project\dreamhouse-sfdx$ sfdx force:auth:web:login -d -a DevHub

\VSCodeQuickstart\my_sfdx_project\dreamhouse-sfdx$ sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org
  • That worked for me.
    – Json
    May 2, 2019 at 21:33

When working on multiple projects I am of the opinion it is a bad idea to have a default devhub org set; only a matter of time when a command gets executed against the wrong org :).

I don't have a default org set and explicitly specify it with --targetdevhubusername= when needed:

$ sfdx force:auth:web:login -a sf3
$ sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org --targetdevhubusername=sf3
  • BEST ANSWER FOR ME!!! It's super important to note that in the real world where you work with multiple projects at a time it's a terrible idea to set a default org. Thanks for this valuable additional information!!
    – Bahman.A
    Mar 30, 2021 at 23:11

I faced the same issue. To resolve it, do the following step :

  1. Re auth your org in ebikes-lwc folder(or your named folder) via following

    sfdx force:auth:web:login -d -a ebikeslwcOrgAlias
  2. Now try to create scratch org :

    sfdx force:org:create -s -f config/project-scratch-def.json -a ebikes

enter image description here

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.