You need to sign in to do that
Don't have an account?
Lokesh Krishna Sagi
VS Code - localhost 1717 error while Authorizing an Org
Hi All,
I am trying to authorize an org (Dev org not sandbox) from VS Code and I am in my Company network and default port Id 1717 wouldnt work for me. I have followed the below steps to create a Connected App and change port number in sfdx-project.json file. But still its taking me to old 1717 localhost even after changin the port number.
From Connected App..
From VSCode project setup..
I have also tried to put 443 in the redirected URL instead of 1717. But it doesnt work either.
Is there any mistake that I have done while setting up the Conncted App ? BTW, I am not using JWT AUthentication. Its just web based authentication. How else can I change the default port number ?
PS : I have used both "oauthLocalPort" : "443" and "oauthLocalPort" : 443.
I am trying to authorize an org (Dev org not sandbox) from VS Code and I am in my Company network and default port Id 1717 wouldnt work for me. I have followed the below steps to create a Connected App and change port number in sfdx-project.json file. But still its taking me to old 1717 localhost even after changin the port number.
From Connected App..
From VSCode project setup..
I have also tried to put 443 in the redirected URL instead of 1717. But it doesnt work either.
Is there any mistake that I have done while setting up the Conncted App ? BTW, I am not using JWT AUthentication. Its just web based authentication. How else can I change the default port number ?
PS : I have used both "oauthLocalPort" : "443" and "oauthLocalPort" : 443.
Greetings to you!
Please refer to the below links which might help you further with the above issue.
https://salesforce.stackexchange.com/questions/208158/authorizing-dev-hub-from-force-com-ide2-redirects-to-localhost-after-authorizing
https://salesforce.stackexchange.com/questions/249857/cannot-connect-a-salesforce-org-using-authorize-an-org-in-vs-code
https://salesforce.stackexchange.com/questions/251589/unable-to-authorize-salesforce-org-using-sfdx-trailhead
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
I have been stucked for 2-3 days and finally I pray and have the idea to change to using another browser (from Edge to Chrome, it works).
Thanks Lord Jesus!
Did your issue got solved. I am facing the same issue from the last few days. It will be great if you can share us the solution if found.
Thanks,
Shamsher
Faujiya,
After working with Salesforce Support, I was able to fix my issue using this article (https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_env_variables.htm) below. I am not sure we can assign a port, it will basically redirect back to 1717. On the article all you do is add a new Environment Variable as described at the bootom of the page on the article and it worked.
Add Environment Variable NODE_TLS_REJECT_UNAUTHORIZED with a Value of 0
Full link:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_env_variables.htm
Hope this helps ya.
I see that you are getting the above error while authenticating the org.
Can you try adding the below line project.json file and try it.
"oauthLocalPort" : "1919"
Kindly let me know if this helps. If it does please close this question by marking a best answer so that it would help others in the future and also helps the community in keeping it clean.
Thanks and Regards,
Anutej Poddaturi
Thank you for your reply. I had already tried that option but it didn;t work either. I got my chrome recently updated to 80 version and it was my default browser. I changed my default browser to IE and it started working for me. After almost 5 days, finally got it working by changing the default browser to IE. (it might work with Edge too, but I have not tried it).
Regards,
Faujiya Mandrupkar
I hope this helps.
Regards,
Faujiya Mandrupkar
@Vishesh....thanks! it worked for me...
I faced this issue and resolved:
Error Message: when i was trying to auth org using vs code it was showing below error message:
ERROR running force:auth:web:login: grant type not supported
or
page is redirecting on localhost:1717 and not auth org failed
Solution:
Open Terminal window in MAC, type top, you will see 1717 in that not down PID number that may be 1717, close this terminal
Open another terminal, type below command:
kill -9 1717 Press Enter
The process that’s running on 1717 port will be kill, again authorize your org from vs code, issue will be resolved.
I had the same using custom domain login
The issue that I have was putting salesforce URL instead of my domain URL while "New Org" VC Code Command
Setup/My Domain
Your domain name is: https://xxx-nzahorg-zxc--cscdev.my.salesforce.com
https://xxx-nzahorg-zxc--cscdev.lightning.force.com - salesforce org - wrong
https://xxx-nzahorg-zxc--cscdev.my.salesforce.com - mydomian - correct
#LCAnswers #BeASalesforceChamp
Authorize your org with a custom URL from VS code using salesforce's classic URL. It will definitely work.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved.
Thanks and Regards,
Rahul Jangir
I hope it helps you.
1 . JAVAHOME set
2. Run command in the terminal
sfdx plugins:install @salesforce/plugin-auth@1.4.3
3. Run command in the terminal
sfdx auth:web:login --setalias myOrg --instanceurl https://login.salesforce.com --setdefaultusername
None of the solutions above work, nor should they be used.
Salesforce CLI is just broken,
So until Salesforce fix it use:
sfdx auth:device:login -a MyAlias -r https://<mydomain>--<sandbox>.my.salesforce.com -s
chen huanchong, that work fine form mi. Thanks very much.
@Rahul Jangir 2's solution of using the Classic URL did the trick for me. Thanks Rahul
WINDOWS PC Only... (don't use taskmanager!)
Using VSCode, open a new "cmd" terminal
OR Using Command Prompt for Windows (Click start, type "cmd" press enter)
1) c:\ netstat -ano | findstr :1717
-a = Displays all connections and listening ports.
-n = Displays addresses and port numbers in numerical form.
-o = Displays the owning process ID associated with each connection.
2) c:\ taskkill /PID [YOUR PID] /F
/F = Specifies to forcefully terminate the process(es).
3) Press F1 and do SFDX: Authorize an Org.
Wait for the CLI to pop up and ask questions, don't interrupt it. Name your connection and GO! It should work now.
Note about sfdx_project.json:
I recommend using your mydomain name for the sfdcLoginUrl in the sfdx-project.json file. Just make sure you get it from Classic, not Lightning. It should look like this: "sfdcLoginUrl": "https://corpadefakeo-sandbox1.my.salesforce.com".
Speaking to windows here, the root cause of this issue is port exclusion by the WINNAT service (winnat randomly reserves some ports and disallows use by other processes). If WINNAT is not configured to leave port 1717 alone, it will randomly hold it (held ports can change with each reboot of your PC, causing the issue to appear random, or to fix after a reboot).
Run this command from a cmd prompt to see if port 1717 is being held by WINNAT:
netsh interface ipv4 show excludedportrange protocol=tcp
The command above will give output like this, in this case 1717 is between 1684 and 1783, so I am affected by the issue:
Start Port End Port
---------- --------
80 80
1025 1124
1545 1644
1683 1683
1684 1783
1784 1883
1884 1983
1984 2083
If it is, you have to stop the winnat service, exclude port 1717, and restart it using these commands (admin command prompt):
1)
net stop winnat
2)
netsh int ipv4 add excludedportrange protocol=tcp startport=1717 numberofports=1
3)
net start winnat
After running those commands, try your "SFDX: Authorize an Org" again.
Root cause of this issue is node.js not using a properly reserved port for oAuth (1717) (SFDX uses node.js for oAuth processes as I understand it), but rather using a random port that just happens to be reserved by Microsoft (Microsoft Convoy).
Error URL:
localhost:1717/OauthRedirect?error=OAUTH_APP_BLOCKED&error_description=this+app+is+blocked+by+admin&state=eefcbed43edd
Error Description:
this app is blocked by admin
This is most likely not an error with the Salesforce CLI. Please ensure all information is accurate and try again.
Solution: Go to your sandbox to Connected Apps and Unblock the 'Salesforce CLI' App. Refer screenshot. This resolved the Salesforce CLI issue I was facing.
Using custom url option with salesforce classic login url solved the issue for me. Thanks Rahul Jangir.
Here's what I did
1. Login to salesforce org
2. Switch view to salesforce classic from "view profile" option at the top right corner
3. Log out (click on user name)
4. Copy the url from logged out page
5. Use this url in the Custom option while Authorizing an org
Example: https://<domain-name>.my.salesforce.com
Below is what worked for me
Updated the port as below to some unused port in sfdx-project.json (Found in each project in the main directory)
"oauthLocalPort": 7714
made sure this port is not being used (by running the command "top" in mac os).
used the command. sfdx force:auth:web:login -a <alias> (replace <alias> with your org name)
this will take to authorization after sucessful login. see if the oAuth redirect URL has the same port as the one mentioned in "oauthLocalPort" in sfdx-project.json , if not just replace the port in the URL with the one mentioned in the sfdx-project.json and hit the URL again and Authorization Sucessful !
1) vscode java.home is set with latest version.
2) Updated the port as below to some unused port in sfdx-project.json (Found in each project in the main directory)
"oauthLocalPort": 1909
3)in new termina sfdx auth:web:login -r https://<MyDomainName>--<SandboxName>.sandbox.my.salesforce.com
4) This will take to authorization after sucessful login. see if the oAuth redirect URL has the same port as the one mentioned in "oauthLocalPort" in sfdx-project.json , if not just replace the port in the URL with the one mentioned in the sfdx-project.json and hit the URL again and Authorization Sucessful if not take leave for today :)