Not sure what's going on here but I'm following the following trailhead and trying to authorize my dev org for use with vs code:


When I run the command:

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

The browser opens to the login page then after I login i get the error:

This site can’t provide a secure connection

localhost sent an invalid response.

It redirects to https://localhost:1717/OauthRedirect?code={{code}}

I read many posts where the issue seems to be a network or firewall issue or another process already listening on that port. I verify that there's nothing listening on port 1717 before i run the sfdx command and when I run the command i'm not getting a refused error or anything in fact after I run the command in a separate window i run:

netstat -ano | findstr 1717

and can verify that the process listening on that port is sfdx. For good measure i tried to use a different port as others suggested by specifying oauthLocalPort in the sfdx-project.json file. When I do this the redirect still goes to port 1717 at which point I do get a connection refused, which I would expect as no one is listening there now, I change the port on the URL to the one i specified and i'm back to square 1 which is the error:

localhost sent an invalid response.

If anyone can shed anymore light on this it would be appreciated.

  • r u vscode commands are running any corporate firewall network?
    – sdandamud1
    Jul 2, 2019 at 19:50
  • @sdandamud1 No i'm not Jul 2, 2019 at 19:51
  • then you have to go through link salesforce.stackexchange.com/questions/226114/…
    – sdandamud1
    Jul 2, 2019 at 19:55
  • @sdandamud1 I tried that already along with creating a new connected app and specifying a different port, no luck on both accounts Jul 2, 2019 at 20:03
  • i think it's look like issue with your network, your machine network running under firewall
    – sdandamud1
    Jul 2, 2019 at 20:10

1 Answer 1


It may be that your chrome HSTS settings force the use of https for localhost. See if deleting the HSTS for localhost per https://www.thesslstore.com/blog/clear-hsts-settings-chrome-firefox/ works for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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