2

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

2

9 Answers 9

5

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!

2
  • Waw you just saved my day! Couldn't get any other solution working, had tried reinstalling sfdx, resetting config, all without success. This was the only solution that worked.
    – Danyright
    Mar 4, 2021 at 10:15
  • This has been the only one that worked for me after trying everything else!! Thanks!! Apr 3, 2021 at 5:41
2

IT turns out I was trying to connect to my sandbox with the production SFDX Org, in the Authorize an Org, be sure to select test.salesforce.com.

1

Seems like what's happening is, SFDX sets up a temporary web server on your own computer so that when your OAuth flow is finished, the browser has a way of handing the token back to SFDX and signalling that it's completed the flow.

So if you are unable to reach that localhost:1717 URL... why? It's located on your own computer. So either you have an internal firewall that is blocking your computer from browsing to itself, or your browser is contacting something other than your local computer when it aims at "localhost" (hence why some suspected proxy settings). Or something has blocked SFDX from setting up the local server in the first place.

1

OK, the OP's edit says that proxies are not the issue.

Before looking too far afield, try looking at your event log for suspect errors; see if that helps you locate the source of the problem.

You can also try disabling all firewall and antivirus software, then run

sfdx force:auth:web:login

from a CMD prompt. If "sfdx force:auth:web:login" still fails, remember to re-enable your firewall/AV :-).

Try next disabling other software, like "Intel(R) Management and Security Status" or other things clearly related to security. If that fails to get "sfdx force:auth:web:login" working, you can try starting your computer in safe mode (many ways to do this, like run "msconfig" and tell your computer to boot in safe mode with networking; you can also often do this by banging the F8 key on boot, if you can get the timing right).

Log in (in safe mode) and try running "sfdx force:auth:web:login" from a CMD prompt again; if it works, some non-essential service is stopping things from working. Remember to run run msconfig again and reset the computer for a regular boot, then reboot and continue - assuming you have rights to do this.

To see what service might already be binding to port 1717 on the local host, run

netstat -ano | findstr 1717

from a CMD prompt. If you see a line of text that suggests something is in fact running on port 1717, run

netstat -ano | more

and hit the spacebar until you get down to that line; note the process and kill it.

There's more you can do, but eventually you'll want to grab someone with local knowledge, who can log into your machine and perform administrative tasks for you and troubleshoot. I'm hoping your employer sees this as part of doing your job.

0
                          General Environment Variables

HTTP_PROXY

If you receive an error when you install or update the Salesforce CLI on a computer that’s behind a firewall or web proxy, set this environment variable. Use the URL and port of your company proxy, for example:

http://username:[email protected]:8080

HTTPS_PROXY

If you receive an error when you install or update the Salesforce CLI on a computer that’s behind a firewall or web proxy, set this environment variable. Use the URL and port of your company proxy, for example:

http://username:[email protected]:8080

Environment Variables

You can set environment variables to configure some values that Salesforce CLI and Salesforce DX tooling use.

Salesforce CLI Environment Variables

Environment variables override CLI runtime configuration values.

Reference:- Environment Variables and Use the Salesforce CLI from Behind a Company Firewall or Web Proxy

0

Just simply add your windows environment local variable "HTTP_PROXY" and "HTTPS_PROXY", you may need to log off your machine.

0

I had the same 1717 error attempting to authorize an org.

I neglected to open my project first and include a username along with the org name that I was looking to authorize using Visual Studio Code.

Allison

0

I was facing the same issue, but then I tried below and got solved.

  1. Go to -> sfdx-project.json file in your vs code
  2. Add "oauthLocalPort" : 1717 This worked for me just now.

Check oauthLocalPort Tag

-1

I have exactly the same issue after my upgrade my old PC(WIN7) to WIN10. I used to try millions of tests with different approaches(proxy, JAVA setting, system envrionment variables, firewall rules) online but no one works, With last chance I noticed there is an error message that related the salesofrce extension under the Log(Window) in Visual Code:

enter image description here

Which made me feel there must be something wrong with extension itself. So I re-installed this extension and it WORKS!!!

You must log in to answer this question.

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