[SalesForce] Cannot connect a Salesforce org using Authorize an org in VS Code

Using VS Code, after I enter the command line "Authorize an org" I get redirected to Salesforce login and can successfully log in. However I then get the error

"This site can't be reached"
The URL displayed used is http://localhost:1717/OauthRedirect?code=aPrxSV6UAcNrPEmQv5Rcj1tOKwXOkQhSqqbQE8Skbj7KLvIetoWmK4wCx0yNhoHrSP7OV95DAA%3D%3D&state=7ec3c8452f21

I am in a company network so cannot check if port 1717 is free/allowed. Should I try to change the redirection URL to another port using a connected app ? I am a bit lost here. Any help much appreciated. Thanks !

enter image description here

Edit (21/2) – Apparently I cannot add a comment to my own question on this forum so editing the original post – I am 100% sure I am not connected behind a proxy

Edit (22/2) – This is my work computer so I don't have permission to do many things …
What is really weird is that I can successfully connect to Salesforce using CLI through command line

Best Answer

There's a different login flow that's intended for other devices where this local webserver setup isn't feasible, but it's actually a great way of dealing with this exact issue on desktops too!

You may need to use the command line directly instead of invoking via the command palette, but it's a simple command:

sfdx force:auth:device:login

It gives you a code you have to enter to join things together (rather than the automatic callback to a local webserver), and once done you should be able to invoke all the usual sfdx commands from within VS code.

Remember to use sfdx force:auth:device:login --help if you need more information on the command!

Related Topic