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

5 Answers 5


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
    Commented 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
    Commented 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


I know this is an old thread but here is my finding who needs it. Need to provide


Like this

    sf org create scratch --definition-file config/project-scratch-def.json --alias MyScratchOrg --set-default --edition=developer
  • 1
    Note that the reported error message was "Must pass a username..." Do you want to state that you get this error message by not providing the edition parameter in the prescribed way?! This is not even a required parameter - see here. Commented Mar 8 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .