I have created a scratch org on my home machine and it is active and can be seen in the devhub. And I am now on my office computer.

However, when I use sfdx force:org:list I can't see that particular scratch org. And if I directly use sfdx force:org:open -u [userName] it comes back with an error message. And I am not quite sure what the password is for that particular scratch org.

What should I do in this case?

sfdx force:org:list

The above command is specific to the machine you used. So don't think your office laptop has any knowledge of what orgs you authenticated with and set as the default hub org and the default scratch org.

You will need to authorize all the orgs you have with your office laptop again, and create your scratch org again from the office CLI.

Follow the below steps

1.Again authorize your scratch org using the sfdx force:auth:web:login and entering the username and password

2.Use force:config:set to set the default scratch org

sfdx force:config:set defaultusername=test-wvkpnfm5z113@example.com

Optioanlly you can use sfdx force:alias:set to set alias as well default scratch org and the hub org .

  • 1
    Thank you, Mohith. I will check them. But currently your link is pointing to about:blank. And I have noticed that I need to generate my password for my scratch org user before it has one. So does that mean I can't login to my scratch org before generating the pwd? – Lance Shi Jan 25 '18 at 5:53
  • I think you have to. But anyway, you shouldn’t worry too much about a specific scratch org. Everything should be in your repo, as Scratch orgs are ephemeral, so just git clone your repo again and create a new Scratch org from it. – Fabien Taillon Jan 25 '18 at 8:00
  • well, I started work on my scratch org at home, and now you're telling me I can't pull that code into my project here at work - I have to wait until I go back home again and pull the changes out and commit to my VCS – bkwdesign Mar 1 '19 at 15:54

Here are the commands I used to reconnect to a scratch org that was initiated on another machine. Please note, I had my .sfdx/ folder included in my git repo, so the org definition existed when I pulled my code down to my other machine.

It was not necessary to reauth to the scratch org in this case (which would be difficult since the password is not known).

shanekenyon@Shanes-MacBook-Pro ~/Documents/git/csvupload (master) $ sfdx force:config:set  defaultusername=dev
=== Set Config
NAME             VALUE
───────────────  ─────
defaultusername  dev
shanekenyon@Shanes-MacBook-Pro ~/Documents/git/csvupload (master) $ sfdx force:org:list
=== Orgs
  ALIAS      USERNAME                     ORG ID              CONNECTED STATUS
  ─────────  ───────────────────────────  ──────────────────  ────────────────
  devhub     userid@domain.com            ****000001Uj0****   Connected

     ALIAS  SCRATCH ORG NAME     USERNAME                       ORG ID              EXPIRATION DATE
───  ─────  ───────────────────  ─────────────────────────────  ──────────────────  ───────────────
(U)  dev    shanekenyon Company  test-t8k7wnruwd66@example.com  ****000000982****   2018-10-23
  • 1
    Just seeing this now .Storing .sfdx folder on git can mean potential security risk . – Mohith Shrivastava Feb 19 '19 at 14:16
  • Yeah its not a good idea to have the .sfdx folder in the repo. We stopped doing it a while ago because it simply causes problems and doesn't work all that well. There is no reason to share scratch org creds, and you rightly point out that keeping sandbox org auth there is a security risk and violation of the principle to keep "secrets" out of source control. – Shane Feb 19 '19 at 17:30

If you used your own connected app to authenticate with the DevHub which was used to create the scratch org, then you can use that connected app to connect to any scratch org created using the same connected app.

You'll need the username, your connected app's private key and your client id (consumer key)


sfdx force:auth:jwt:grant -u test-abcdefgh@example.com -f server.key -i <ConsumerKey> -a <MyAlias> -r https://test.salesforce.com

Full documentation here under Authorize a Scratch Org


If possible on your home machine use

Sfdx Force:user:password:generate -u orgalias

The use the username and password displayed to authenticate from your work machine

If you need the password again use

Sfdx force:user:display

Not sure if the work machine would recognize it as a scratch org but you would then have it connected

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.