I recently refreshed my developer sandbox.

In VS Code, I ran

sfdx force:auth:web:login --setalias aliasName --instanceurl https://test.salesforce.com --setdefaultusername

It opened the OAuth window and I logged in. I noted that I wasn't prompted to grant access permission to SFDX cli, nor do I see such an app in the sandbox's app manager.

Back in VS code, if I run

sfdx force:org:display --targetusername aliasName

I get an org description of my sandbox the a Connected Status of 'Connected'. If I run sfdx force:org:open, my sandbox opens in browser.

When I open the context menu on files in my local repo I see options for SFDX: Deploy Source to Org and SFDX: Retrieve Source from Org..

And yet, when I attempt either one of these, I get the following error:

'Error authenticating with the refresh token due to: expired access/refresh token'

If I had to guess this has to do with me not having a proper connected app set up in my sandbox, but I'm not sure what step to take other than authorizing the org through SFDX. What am I missing?

August 2023 Update: If you're coming here at this point, I'm guessing you haven't yet gotten off SFDX and onto SF, the new CLI space that Salesforce is introducing. They offer instructions on how to uninstall the SFDX CLI and install SF CLI instead, which has its own set of similar commands that will now related to the deploy and retrieve context options you see in VSCode.

So if you're looking to troubleshoot, first step should be to uninstall SFDX and get on the latest version of SF, then retry.

6 Answers 6


This is a bug/feature of a recent change to the Salesforce CLI to use REST by default (whereas it previously used SOAP to deploy/retrieve).

You can avoid this issue for now while they (the sf cli team) work out the kinks by disabling restDeploy

sfdx config:set restDeploy=false (add the -g flag to the command if you want to make that global).

You can achieve the same thing by adding "restDeploy": "false" into the sfdx-config.json for an sfdx project (in the .sfdx directory)

  • 1
    Thanks for the info! Unfortunately changing this setting doesn't seem to have solved the error.
    – smohyee
    May 6, 2021 at 15:51
  • 1
    I have same issue, and restDeploy:false didn't help. please advise. Oct 8, 2021 at 1:15

OK, looks like my issue was very basic. I authorized the org, but I didn't set it as my default org. Once I ran

sfdx force:config:set defaultusername=aliasName

I stopped getting authorization errors.

Still not sure why I was getting an expired refresh error because of not setting this, but at least the issue is fixed!

  • You should mark this as your answer. It didn't work for me, but could help someone else. Oct 8, 2021 at 1:19

I had a similar issue when connected to a developer sandbox, and none of the above worked. I had to login to my sandbox -> go to Connected Apps Oath Usage -> Click Block under VSCode -> Click Unblock -> Reauthorize my org in VSCode


So one of my admins was having a similar issue... turns out he had an old SFDX setting still in his settings.json file (didn't get a chance for him to copy/paste it to me, but it was one of the "experimental" deploy/retrieve settings). once it was removed, he was able to retrieve successfully. Scour your settings for any outdated entries and see if removing them helps.

  1. I have just logged out of my sandbox.
  2. Using the same default name i.e vscodeOrg , reauthenticated rather than giving my own default name. Finally It worked when try to deploy changes to sandbox.

After re-authenticating my org (the command has changed so much, I'm not bothering to type it here), I still had to close and reopen VS Code to stop getting this error. No amount of directory deleting or logging out solved it.

You must log in to answer this question.

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