I found some public question which treat this topic, but I didn't get a specific solution.

I have this error message when I try to deploy my files from local to my org.

Error: INVALID_SESSION_ID: Session expired or invalid

It's the first time it happens. I have opened session on this org but I cannot deploy files from local. I tried to do the solution using this command on terminal:

lsof -i tcp:1717

But it does not work.

Any idea? Thanks.


I ran into this issue after I had to change my password in the sandbox. I just ran this command to fix it:

sfdx force:auth:web:login -a <alias> -d -r https://test.salesforce.com

This will open up your browser to login to the sandbox. I was able to deploy to the org after doing this.

(The -r lets you login to a sandbox. Without it, your browser will open to login.salesforce.com.)

  • Just today I had same problem on another deployment and it worked! Thank you dazmae! – CPS Mar 10 at 8:23
  • Thanks - this resolved my issue. Although i didn't have to change my password. – SF Ninja Mar 10 at 21:18

I solved it through the following steps-

At the bottom left of your VS Code you will find a small box icon to 'open the org'enter image description here. Just click on that. Wait till the operation finishes. Then try to deploy again.


In case you're deploying to a scratch org, executing sfdx force:org:list in your terminal should refresh your connections - see thread here

After this command finishes, try deploying again and it should work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.