Skip to main content TDX, the developer conference for the AI agent era is happening now. Watch live on Salesforce+ for exclusive digital content, a revolutionary keynote, and more.
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..

VS Code - localhost 1717 error while Authorizing an Org

From VSCode project setup..

User-added image

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. 

 
33 answers
  1. Mar 2, 2020, 6:17 PM

    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.
  2. Jan 23, 2021, 9:27 AM
    Hi Lokesh Krishna Sagi,

    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
  3. Mar 4, 2020, 10:34 AM
    Hi Vishesh,

    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
  4. Nov 6, 2023, 12:42 PM

    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 :) 

  5. Feb 5, 2022, 5:39 PM

    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).

    WINDOWS PC Only...

    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". 
  6. Jun 29, 2021, 9:26 PM

    @Rahul Jangir 2's solution of using the Classic URL did the trick for me. Thanks Rahul
  7. Feb 26, 2021, 11:29 PM
    Hi people, I can resolve this problem uninstall the "Salesforce CLI" on control panel, and after this I install again, I hope this resolve the problem of everyone, I passed all my day trying to resolve this problem, this is really hard.... tks for all the help. bye.
  8. Feb 10, 2021, 3:07 PM

    I hope it helps you.

    1 . JAVAHOME set

    I hope it helps you.1 . JAVAHOME set2. Run command in the terminal sfdx plugins:install @salesforce/3.User-added image

    User-added image

    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
0/9000