function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Angela Ramirez 1Angela Ramirez 1 

Salesforce CLI: auth web login issue

I properly installed CLI. In a command window, I enter:

sfdx force:auth:web:login -d -a DevHub

in order to log in to the trial Dev Hub that I created. The aforementioned command opens the Salesforce login page in the web browser, so I log in using my Developer Hub Trial Org credentials and click Allow. After that, web browser show me an error: "This site can't be reached. localhost took too long to respond".

This is the URL that Salesforce use after I authenticate in the browser: http://localhost:1717/OauthRedirect?code=aPrxbOND3gL_2LbSR7rKPdvD0XBVk2YpErl3pphY2f3xvZ1wf5SSPJByDleRLPMtzCQWnNGAdg%3D%3D&state=f2f8254fac23

I don't know what happen.

User-added image

User-added image

User-added image
Best Answer chosen by Angela Ramirez 1
Abdul KhatriAbdul Khatri
OK Lets dry below and see if it works

Authorize the CLI to work with your DevHub by typing:
sfdx force:auth:web:login -h
This will automatically open your browser and prompt you to login to the dev hub. Use the credentials that you used to create the Salesforce DX authorized dev hub. Click Allow when the Oauth Flow prompts you to.

Once you’ve gone through this authorization process you can set up an alias using the following command
sfdx force:auth:web:login -d -a DevHub
You should see something like:
Successfully authorized <your-username> with org id 00B1I000000L9r3UCY
You may now close the browser
Now you should be able to open the dev hub using this
sfdx force:org:open -u DevHub
Let me know if this works

All Answers

Abdul KhatriAbdul Khatri
please use the following command to open your DevHub
 
sfdx force:org:open -u DevHub

Pleas make sure you created alias DevHub already by using the following command
 
sfdx force:org:list

 
Angela Ramirez 1Angela Ramirez 1
Hi Abdul,
This is the result:
 
sfdx force:org:open -u DevHub
ERROR:  No org configuration found for name DevHub.
sfdx force:org:list
ERROR:  No scratch orgs can be found.

User-added image

I think the problem is auth response. After I authenticate in the browser, the CLI doesn't receive my Dev Hub credentials, so the "Successfully authorized xxxx@xxxxx.xxx with org id 000000000000" message doesn't appears  in the console.
Abdul KhatriAbdul Khatri

Do you have a DevHub Org? otherwise you first have to create a DevHub using the below link

https://developer.salesforce.com/promotions/orgs/dx-signup

then loing to the above Org created using this command line in you CLI.

sfdx force:auth:web:login -d -a DevHub
Now when you do the following
sfdx force:org:list
You should see something like this

User-added image

I see above you are haing issues login into your DevHub. Whey it is directing to localhost.....
 
Angela Ramirez 1Angela Ramirez 1
Yes, I'm have a DevHub Org.

I login into DevHub Org without problem when I use https://login.salesforce.com/ login page. However, when I use command line in my CLI in order to login, the redirect option fail (callback) and CLI doesn't connect with my DevHub Org
Abdul KhatriAbdul Khatri
OK Lets dry below and see if it works

Authorize the CLI to work with your DevHub by typing:
sfdx force:auth:web:login -h
This will automatically open your browser and prompt you to login to the dev hub. Use the credentials that you used to create the Salesforce DX authorized dev hub. Click Allow when the Oauth Flow prompts you to.

Once you’ve gone through this authorization process you can set up an alias using the following command
sfdx force:auth:web:login -d -a DevHub
You should see something like:
Successfully authorized <your-username> with org id 00B1I000000L9r3UCY
You may now close the browser
Now you should be able to open the dev hub using this
sfdx force:org:open -u DevHub
Let me know if this works
This was selected as the best answer
Abdul KhatriAbdul Khatri
Was the last solution helpful?
Angela Ramirez 1Angela Ramirez 1
Hi Abdul,
Thanks you so much!
I have following your steps and these resolve the problem. However I changed a bit your first command, I removed -h flag, so I used the following command:
sfdx force:auth:web:login

 
Narsimha RaoNarsimha Rao
Hello, 
I have been trying to log in to dev hub using the CLI but weirdly when I use the force:auth command the browser doesn't even open. I am very new to using the CLI and please let me know if I'm missing something.

Thanks in advance!
Rich FiekowskyRich Fiekowsky
@Narsimharaot  - I had success by first opening the desired org in the browser, and then, entering the sfdx force:auth:web:login command on the command line. For me, it then opens another tab, requesting the login again. Possibbly we both are missing something else!  
Yashita Goyal 17Yashita Goyal 17
When running any authorize DevHub org command am getting this error:
!    'ENOENT': spawn cmd ENOENT
Abdul KhatriAbdul Khatri
try re-installing the SalesforceDX CLI
theseptemberguytheseptemberguy
HI @Angela Ramirez 1: I am also facing exactly the same issue. It works perfectly fine in my personal laptop & desktop but failes at the same step in my office desktop. Sound like a proxy/firewall issue. If you find a solution please share it. Thanks.
Richard Goerwitz 15Richard Goerwitz 15
Couple of things to try, initially:
  • If stuff stopped working recently, go into your Control Panel, then Programs and Features, and sort by install date; look at recent installs
  • If uninstalling recent, but dispensible stuff that might affect security/networking doesn't get you a fix, keep going...
  • 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, and keep going
  • Try next disabling other software, like "Intel(R) Management and Security Status" or other things clearly related to security
  • If that fails start in safe mode (many ways to do this, like run "msconfig" and tell your computer to boot in safe mode with networking)
  • Log in and try running "sfdx force:auth:web:login" from a CMD prompt again; if it works, some service is stopping things from working
  • If you have your computer running in safe mode, run msconfig again and set it for a regular boot, then reboot and continue
  • 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, 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.
 
meena Vangalameena Vangala

@ theseptemberguy
set http_proxy=<Username>:<Password>@host:port(try to set this in command prompt ) 

Replace ur Username,password,host and port something like ths 
set http_proxy=mvangala:March2019@sgproxy.gfoundries.com:8080(For my system)
it will work 
  
Ryan BoosRyan Boos
Was doing trailhead --> https://trailhead.salesforce.com/content/learn/modules/sfdx_app_dev/sfdx_app_dev_create_app
attempted run the command --> sfdx force:org:create -s -f config/project-scratch-def.json -a GeoAppScratch
Received the error -->  "Must pass a username and/or OAuth options when creating an AuthInfo instance."

Followed the above solution posted by [Angela Ramirez 1].
* Used the recommended command [sfdx force:auth:web:login]
* Then reran the command [sfdx force:org:create -s -f config/project-scratch-def.json -a GeoAppScratch]
Resulted in --> "Successfully created scratch org:"

Thank you for helping!
Hernán MorgadoHernán Morgado
Hi, for this error

 'ENOENT': spawn cmd ENOENT'

Try to verify the enviroment variable 'Path'. You need to specify the path of CMD. If you dont specify this, the cmd launch in the project path and you need launch this in system32. Also, verify the port 1717 if this is free with the command netstat -ano | findstr 1717 and then kill with TASKKILL /F /PID 17956. Moreover, you 'Path' need 3 path (Salesforce bin folder path - Visual code bin folder path - CMD path) for example:

C:\Program Files\Salesforce CLI\bin;C:\Users\herna\AppData\Local\Programs\Microsoft VS Code\bin;C:\Windows\System32;

And finally verify if you have JDK_HOME and JAVA_HOME enviroment variable set in your pc.

With this action i could to launch vscode succesfully whit any command and i could to deploy my first apex class.

Please tell me if this information was useful for you.
Regards! 
:)
Viswanath Kambhampati 12Viswanath Kambhampati 12
@Meena Vangala -- thanks it worked
nitisinghnitisingh

Hi @meena Vangala,

Still i am facing the same issue i am connecting vscode with my project sandbox , i am getting below error. Please help . 

User-added image

nitisinghnitisingh

Hi @Viswanath Kambhampati 12

what you have done for the error . can you explain 

meena Vangalameena Vangala
Hi @nitisingh 
Please use the below command 
sfdx force:auth:web:login -r https://login.salesforce.com 
or
sfdx force:auth:web:login --setdefaultdevhubusername --setalias my-hub-org

Make sure you enable devhub in your org



 
nitisinghnitisingh
Hi @meena Vangala : I am connecting with Sandbox URL not Production . Please let me know . 
meena Vangalameena Vangala
hi @nitisingh 
you can change the url of production to your Sandbox
sandeepreddy Uppulasandeepreddy Uppula
@nitisingh@Meena@Viswanath Kambhampati 12

Can you please help me out how you are able to solve localhost:1717 error post login to salesforce.
 
sandeepreddy Uppulasandeepreddy Uppula
i have followed everything being told above, still unable to proceed further. i am tryig to connect from a corporate(Office) network. With my personal lappy i do not face any error. Kindly let me how you are setting the proxy and user(system) authentication which seems to be a problem here.
Abdul KhatriAbdul Khatri
@sandeepreddy,

Can you shared your sfdx-project.json file contents? I am interested to see what is the sfdcLoginurl you have set.
Steven MannSteven Mann
Make sure Salesforce CLI app is installed within your org. Setup -> Connected Apps OAuth Usage (if button next to Salesforce CLI is labeled Install then click it because it isn't installed).

Also, make sure you have the following permission sets:
  • Modify All Data
  • Use any API client
Absar Ahmad 8Absar Ahmad 8
Thanks for @Hernán Morgado
This work for me set all the three paths to system path variable and JAVA_HOME path now it's work in VS Code
Omsai DevarasettiOmsai Devarasetti
Hey @Hernán Morgado , I have environment varibles set in account level and not system level. I have set CLI,VS Code, Cmd paths respectively.

But still i am facing the issue as localhost 1717 error. I have checked for PID but didnt found any.

I have added below parameter in sfdx project json but no luck.

"oauthLocalPort" : "1919"

Is there anything that i am missing here?

Regards,
Sai
Dineshsing Girase 18Dineshsing Girase 18
@Omsai Devarasetti - 1. Make your default browser to Google Chrome and try.
2. It it wont fix the issue, then you need to kill the process currently using a port on localhost in windows
https://stackoverflow.com/questions/39632667/how-to-kill-the-process-currently-using-a-port-on-localhost-in-windows
Pinki Rani JaiswalPinki Rani Jaiswal
Hello Friends , 
I am also facing Localhost issue .
User-added imageUser-added image
Simon DixonSimon Dixon

I had the exect same problem with localhost:1717 with the web login flow, so I used the device flow instead
 

sfdx force:auth:device:login
reference:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_auth.htm#cli_reference_device_login
Pinki Rani JaiswalPinki Rani Jaiswal
I was able to resolve the issue today. I was using the incorrect user name.  We need to use the User name which we receive through email from Developer Edition administrator. You need to reset your password first and then use the user name from your email and login.

Thank you!
kavya mareedukavya mareedu
Hello Team, 
 
I get the same error as the guy in the top mentioned and even after following all the steps you guys have mentioned, my issue is still not resolved.
 
kavya mareedukavya mareedu
User-added image

How to solve this issue?

Help me I have spent my whole half day fixing this issue and still there is no luck.
Son Nguyen VNSon Nguyen VN
Hi guys, 

The Salesforce CLI use NodeJS to handle the authentication between client and Salesforce server 

When you use a proxy or your network not transparent the https will occur the error

You can skip the error by set bellow variable in environment on your pc
NODE_TLS_REJECT_UNAUTHORIZED = 0
Note: you must restart the CMD or VSC after set variables.

How to creating and Modifying Environment Variables on Windows
https://docs.oracle.com/en/database/oracle/r-enterprise/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html
 
Dineshsing Girase 21Dineshsing Girase 21
Hi All, i am getting below error
ERROR running force:package:install: Must pass a username and/or OAuth options when creating an AuthInfo instance.
on line
sfdx force:package:install --package $PACKAGE_VERSION_ID --wait 10 --publishwait 6 --noprompt
Kid JansenKid Jansen
Also been having issues with this on my personal desktop PC for the past few months:

 
PS C:\Users\Kid Jansen> sfdx force:auth:web:login
ERROR running force:auth:web:login:  Command failed with response.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

 - The argument 'C:\Users\Kid Jansen\AppData\Local\sfdx\client\7.48.0-a71f8c6899\node_modules\salesforce-alm\CredMan.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.


Try this:
Determine why this command failed to get an encryption key for user Kid Jansen: [C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -File C:\Users\Kid Jansen\AppData\Local\sfdx\client\7.48.0-a71f8c6899\node_modules\salesforce-alm\CredMan.ps1 -GetCred -Target sfdx -User local].
 

Running the following versions and settings:
  • Salesforce CLI 7.48 (latest)
  • Visual Studio Code 1.42 (latest)
  • Chrome 80 (latest)
  • JRE 8 u241 (latest)
  • JDK 8 u241 (latest)
  • Windows 10 with all updates
  • don't have any proxies configured
  • not using VPN


What I've tried so far:
  • Tried multiple orgs, have issue both with customer orgs as well as dev orgs (System Administrator profile in all cases)
  • Verified that Salesforce CLI connected app is installed
  • Checked IP restrictions in Salesforce
  • remove and re-install CLI, VSC, JRE and JDK
  • "Install-Module CredentialManager -force" in Powershell 5.1
  • switch from Chrome to Edge as default browser
  • run login command from Powershell 5.1 instead of from VSC
  • run in safe mode with networking (so with ESET Internet Security not booted) -> not working either
  • "netstat -ano | findstr 1717" -> nothing running on that port

It used to work on this machine up until a few months back. It also works on my work laptop (Capgemini, so that'll have a ton more security enabled) on any network I've tried so far (home, at office, at customer), but like said it doesn't work on my desktop PC on my home network.
Kid JansenKid Jansen
Forgot to mention I also removed the installation folders for the Salesforce CLI in both "C:\Program Files" and "C:\Users\Kid Jansen\AppData\Local" after uninstalling it and before re-installing. Also checked registry with RegEdit to see if any keys were left after uninstall, but couldn't find any.
ShrawanShrawan
@kavya I am getting the same error. Did you ever find a solution? Also, I tried the devide login flow but I am getting Access Denied after I enter the verification code in the browser. Any help would be appreciated.
Dineshsing Girase 21Dineshsing Girase 21
@kavya and @Shrawan - from your sfdx-project.json, change the port to other than 1717. You can try this - "oauthLocalPort" : "1919"
ShrawanShrawan
I changed the oauthLocalPort to 1919 but still getting the same error. Browser still redirects to 1717 after login
Kid JansenKid Jansen
Not sure what the issue was, but recently replaced my old SSD boot drive with a newer bigger faster SSD and did complete reinstall of Windows and all software and now it works like a charm again. So if all else fails it's worth considering format with complete reinstall.
Iyyappan ManeeIyyappan Manee
Please delete http_proxy and https_proxy from system properties (environment variable) sure it will work
Natalya MurphyNatalya Murphy
The following solution was originally posted in this thread (https://developer.salesforce.com/forums/?id=9060G000000Bj0IQAS) and solved my problem.  In my case I'm on a Windows system so the path to the folder of interest was C:\Users\Natalya\.sfdx
I had the issue on CredMan.ps1 (was unable to login). Steps to fix: Go to the root folder(under your user name) for .sfdx and delete all the files (json). These must have been created from the old logins.
nolascoinnolascoin
What worked for me, even in 2020
 
sfdx force:auth:web:login -a devorg --instanceurl https://YOURDOMAIN.my.salesforce.com

I was getting the same error as the original post, "Verify the OAuth configuration for this org. For JWT" <_<
Jack Volkov 9Jack Volkov 9
I was also receiving the "localhost:1717" error and CredMan.ps1 error.  On a Windows 10 machine.

What solved it for me was in the .sfdx folder C:\Users\[myname]\.sfdx there was a myuser@companydomain.com.json file.  This file contained some tokens and my username.  Deleting this file, then retrying SFDX: Authorize an Org worked.  Perhaps it was trying to auth with these expired tokens?

As a takeaway I at least learned about the sfdx force:auth:device:login -r mydomain.my.salesforce.com command which is a neat way to connect.
Troy CenterTroy Center
The problem, in any case, comes from using a URL that is not supported by the CLI.
 
Modify your sfdx-project.json file. 
Change sfdcLoginUrl from lightning.force.com to my.salesforce.com
Then run (VSCode) SFDX: Authorize an org | Choose Project Default | Call it something | Login | Allow access 
 
Example: 
Change:   "sfdcLoginUrl": "https://insane-membrane-744iv7-dev-ed.lightning.force.com",
to:   "sfdcLoginUrl": "https://insane-membrane-744iv7-dev-ed.my.salesforce.com"
 
Happy New Year. 12/28/2020 Troy ~ Seattle. 
Štěpán BillŠtěpán Bill
If you are having problem with redirecting to locahlost:1717/oAuth..... try to check if you have installed Java (JRE or JDK) and set Environment Variables JAVA_HOME
https://javatutorial.net/set-java-home-windows-10
This helped me. After that I am able to authorized org on SFDX
GAURAV GUPTA 327GAURAV GUPTA 327
Thanks Simon.

In fact, I also struggled a lot with the various methods mentioned above, but finally i could able to authorize with device based login i.e. 
e.g. sfdx auth:device:login -d -a TestOrg1

You need to manually open the URL in the new window and enter the code mentioned below e.g.

C:\Users\48249>sfdx force:auth:device:login -d -a DevHub
=== Action Required!
Enter 05H792KZ user code in the verification URL https://login.salesforce.com/setup/connect


 
Victor LockwoodVictor Lockwood
Wanted to add my two cents - reinstallation worked for me after several hours of troubleshooting ina restarts.  It's a pain, but if all else fails and you can afford to do so, a reinstallation of the CLI (and possibly VSCode extensions - I did those too) may be your saving grace.
Ilin ArgirovIlin Argirov
I've been struggling with this issue for a while now. Victor Lockwood's suggestion to reinstall Salesforce CLI worked for me as well - now I can successfully use the "auth:web:login" flow to authenticate. Thanks, Victor!
Admin MengAdmin Meng
Ilin Argirov. I don't belive you. It's not SF CLI issue.
Daniel ClayDaniel Clay
Not sure if this is the same issue, but I also see something similar on my web app running on MODAPK (https://modapk.tv/) site.
User-added image
Anil Sharma 152Anil Sharma 152
i am also getting same issue in connecting with  https://oneindianet.com/