+ Start a Discussion
Amar SinghAmar Singh 

Salesforce DX - scratch org configuration issue

I am able to create scratch org in DevHub using the following command:
sfdx force:org:create -s -f config/project-scratch-def.json -a "MyScratchOrg".

I logged in to my DevHub org and verfied that a new scratch org record is available under Active Scratch Orgs Tab:

User-added image

However i am not able to open the scratch org:

sfdx force:org:open -u MyScratchOrg
ERROR:  No org configuration found for name MyScratchOrg.

Try this:
Run the "sfdx force:auth" commands with --setdefaultusername to connect to an org and set it as your default org.
Run "force:org:create" with --setdefaultusername to create a scratch org and setit as your default org.
Run "sfdx force:config:set defaultusername=<username>" to set your default username.

I tried the third option with my scratch org username but got the below error:

sfdx force:config:set defaultusername=test-nd1wojndmmid@demo_company.net
=== Failures
NAME             MESSAGE
───────────────  ────────────────────────
defaultusername  No org configuration found for name test-nd1wojndmmid@demo_company.net

Here is the  Scratch org username:
User-added image

Any help or suggestion would be highly appreciated!
Amar SinghAmar Singh
I found this article where it is mentioned as 'Limitations for Salesforce DX'

Dev Hub and Scratch Orgs

Salesforce CLI Sometimes Doesn’t Recognize Scratch Orgs with Communities
Description: Sometimes, but not in all cases, the Salesforce CLI doesn’t acknowledge the creation of scratch orgs with the Communities feature. You can’t open the scratch org using the CLI, even though the scratch org is listed in Dev Hub.
Workaround: You can try this workaround, although it doesn’t fix the issue in all cases. Delete the scratch org in Dev Hub, then create a new scratch org using the CLI. Deleting and recreating scratch orgs counts against your daily scratch org limits.
Amar SinghAmar Singh
Finally Resolved the Issue:

Reason: https_proxy was not set.

Solution: You need to set the both http_proxy and https_proxy as well.
              set HTTP_PROXY=http://username:pwd@proxy.company.com:8080
              set HTTPS_PROXY=http://username:pwd@proxy.company.com:8080 

$ sfdx force:org:list --all
=== Orgs
     ALIAS   USERNAME                       ORG ID              CONNECTED STATUS

───  ──────  ───────────────────────────────────────────────  ────────────────
(D)  DevHub  amar_sfdx@manulife.com.devhub  00D7F000004ewSyUAI  Connected

     ALIAS             SCRATCH ORG NAME  USERNAME                            ORGID              STATUS  EXPIRATION DATE
───  ────────────────  ────────────────  ──────────────────────────────────  ──────────────────  ──────  ───────────────
(U)  amar_scratch_org  Demo Company      test-0tn6jftjtfa0@demo_company.net  00D0l0000000fQCEAY  Active  2018-02-15

Suraj Tripathi 47Suraj Tripathi 47

Please follow these steps to create scratch org.
1. Create a project in VS Code.
2. Authorize your Dev Hub org.
3. Create a definition file of the scratch org.
Then use the command in terminal
sfdx force:org:create -f project-scratch-def.json -a MyScratchOrg --setdefaultusername
For refer- https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_create.htm

If you find your Solution then mark this as the best answer. 

Thank you!

Suraj Tripathi