I followed this really helpful guide to set up my VS Code environment and was able to get my Dev sandbox connected. Now I want to connect another sandbox (e.g. QA) to my VS Code because my goal is to have both Dev and QA sandboxes connected to my VS code. So I followed the same guide again to connect my other sandbox and it works. But I realize it's not very convenient as I always need to remember that when switching to another org, I need to authorize to the other org first before I push something. If not, the changes would go to the previous org because VS code was still connected to the previous org. Does anyone has any good suggestion/best practices on how to set up VS code in a way that allows users to switch smoothly between multiple sandboxes?

1 Answer 1


Authorizing an org should be a one-time affair (well, one time per org). If you refresh a sandbox, you'll need to re-authorize, but if you're doing that with any frequency you should consider using scratch orgs.

After that, if you're using the CLI, the commands to pull/retrieve, push/deploy, download logs, etc... have a -u switch that lets you specify which org to run the command against.

If you're sticking to the UI that the Salesforce Extension Pack provides through VSCode, then you can either Ctrl+Shift+P and SFDX: Set a Default Org, or click the current default org name in the bottom bar of VSCode and change the default org that way

If you select a default org, that's what sfdx will use by default. If you want to use a different org, there's no way around needing to specify which org you'd like to target (through updating your default or using -u)

  • 1
    Thank you for your detailed response derek. I was not aware of the plug icon located at the bottom left corner of VS code which allows me to set the default org for my VS code. Next to the plug icon shows the org that I am connected to. That's very handy because I can quickly look it and confirm that I am connected to the right org before I deploy my changes. Appreciate your help on this!!
    – Jason Fung
    Commented Nov 14, 2020 at 4:30

You must log in to answer this question.

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