I am new in learning lightning web component. I have installed VS Code, salesforce extension pack inside VS code, Salesforce CLI and set environment variable C:\Program Files\Salesforce CLI in my system.

When i am trying to create a new project in VS Code, i am not able to authorize org. I am getting the below error.

Starting SFDX: Authorize an Org

23:45:43.364 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://login.salesforce.com --setdefaultusername
ERROR running force:auth:web:login:  Cannot start the OAuth redirect server on port PortInUseAction. 

Try this: 
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.
23:45:46.30 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://login.salesforce.com --setdefaultusername ended with exit code 1

Please help me out...Thanks

10 Answers 10


The following solution worked for me

  1. Run command prompt ๐š๐ฌ ๐š๐๐ฆ๐ข๐ง (๐˜š๐˜ต๐˜ข๐˜ณ๐˜ต > ๐˜ค๐˜ฎ๐˜ฅ > ๐˜™๐˜ช๐˜จ๐˜ฉ๐˜ต-๐˜Š๐˜ญ๐˜ช๐˜ค๐˜ฌ > ๐˜™๐˜ถ๐˜ฏ๐˜ˆ๐˜ด ๐˜ˆ๐˜ฅ๐˜ฎ๐˜ช๐˜ฏ)
  2. Run the command: ๐ง๐ž๐ญ๐ฌ๐ญ๐š๐ญ -๐š๐จ๐ง
  3. CTRL+F, to search for ๐Ÿ๐Ÿ•๐Ÿ๐Ÿ•
  4. Note the number displayed in the ๐๐ˆ๐ƒ ๐œ๐จ๐ฅ๐ฎ๐ฆ๐ง in the same row where 1717 was found. In my case, it's ๐Ÿ’๐Ÿ”๐Ÿ’๐Ÿ–
  5. Open Task Manager > Click on Details Tab > Sort by PID
  6. Locate the number from step 4 (in my case ๐Ÿ’๐Ÿ”๐Ÿ’๐Ÿ–)
  7. Right-Click > End Task
  8. Go back to VS Code and run the command again "๐˜š๐˜ต๐˜ข๐˜ณ๐˜ต๐˜ช๐˜ฏ๐˜จ ๐˜š๐˜๐˜‹๐˜Ÿ: ๐˜ˆ๐˜ถ๐˜ต๐˜ฉ๐˜ฐ๐˜ณ๐˜ช๐˜ป๐˜ฆ ๐˜ข๐˜ฏ ๐˜–๐˜ณ๐˜จ"

Hope it helps :)

  • 1
    on a Mac, i'm receiving this output when I enter netstat -aon in terminal etstat: illegal option -- o Usage: netstat [-AaLlnW] [-f address_family | -p protocol] netstat [-gilns] [-f address_family] netstat -i | -I interface [-w wait] [-abdgRtS] netstat -s [-s] [-f address_family | -p protocol] [-w wait] netstat -i | -I interface -s [-f address_family | -p protocol] netstat -m [-m] netstat -r [-Aaln] [-f address_family] netstat -rs [-s]
    – rouqeOne
    Dec 21, 2019 at 22:07

Solution straight from the Salesforce DX Developer guide. This worked right away for me on MacOs https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_troubleshoot_cancel_auth.htm

macOS or Linux:

  1. From a terminal, run:

    lsof -i tcp:1717

  2. In the results, find the ID for the process thatโ€™s using the port. Run:

    kill -9 the_process_ID


  1. Press Ctrl+Alt+Delete, then click Task Manager.
  2. Select the Process tab.
  3. Find the process you want to end. Note: If youโ€™re a Node.js developer, you might have several running processes with this name.
  4. Click End Process.

As the error says, port 1717 is not free. Try restarting your computer to see if the error persists. If so, you'll need to use a custom connected app, as outlined in Create a Connected App.

  • after restarting i am getting spawn cmd ENOENT error Apr 8, 2019 at 18:05
  • { Error: spawn cmd ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19) at onErrorNT (internal/child_process.js:415:16) at process._tickCallback (internal/process/next_tick.js:63:19) errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn cmd', path: 'cmd', spawnargs: [ '/c', 'start', '""', '/b', 'login.salesforce.com//services/oauth2/…^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauth0web^&code_challenge=df46V8uJZ7iNP6GC8ZkncYplKgKhKeEeylsSajZtNuc' ] } Apr 8, 2019 at 18:08
  • I faced the same issue and updated the salesforce CLI, It works for me!
    – Annappa
    Mar 5 at 10:55

Error :

{ Error: spawn cmd ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19) at onErrorNT (internal/child_process.js:415:16) at process._tickCallback (internal/process/next_tick.js:63:19) errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn cmd', path: 'cmd', spawnargs: [ '/c', 'start', '""', '/b', 'login.salesforce.com//services/oauth2/โ€ฆ^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauth0web^&code_challenge=df46V8uJZ7iNP6GC8ZkncYplKgKhKeEeylsSajZtNuc' ] }

****** Error **********************************************

To resolve such type of errors occurs while authenticating with salesforce org. We can resolve by adding C:\Windows\System32 in the PATH variable that exists in the Environment setting.

My Computer ->(right click) -> properties-> Advanced system setting -> environment variables and here you can add C:\Windows\System32 this for both system & user variables



I also ran into this problem, and spent 2 days searching it all over the web. Later realized OAuth Redirect might not work while using Custom Login URL of your Org.

Thus while Authorizing Org in VS Code simply use https://login.salesforce.com for Production, and https://test.salesforce.com for Sandbox.


you have two problems. The first is you vs code doesnt execute the console like admin so you have the error 'ENOENT'. Also, you have the port 1717 in use. Try to do this:

Change the enviroment variable 'Path'.

--C:Salesfore path;C:Visual Code path;C:CMD path

For example:

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

If you dont write the cmd path, the cmd start in default folder so you don't have admin privileges.

And for the second error about the port 1717, you cli is using this port when you executed the command 'authorize org' and for the first error this execution dosent finish. So try to kill the process with the nexts commands:

netstat -ano | findstr 1717 (Find the process with pid)

TASKKILL /F /PID (kill the process)


If you have correctly installed VS Code, SFDX CLI and the SF VS Code Extensions then you might just want to try restarting your machine. I have had this same issue occur to me twice on 2 different machines and each time I have only restarted my machine and the issue goes away.

I hope this works for you!


If it's windows try going to settings -> Network & internet -> poxy and turn off auto select. Nothing else that I found worked, but I found a solution here. https://github.com/forcedotcom/salesforcedx-vscode/issues/1818


I was having the same problem in Mac OS. It would take a very long time to authorize. Finally figured out my problem. The Org I was trying to authorize was a sandbox but I was choosing the default which is the production.

So, once I choose the Sandbox option in the authorize an org, it worked!


Not able to open browser to login or change Org This step may help you. Resolve Org Authorization Error in VS Code For example refer the below image: enter image description here

Follow the below steps in order to resolve error:

Go to taskbar, right click and select Task Manager or you can use shortcut(Ctrl+Alt+Delete) Search for โ€œNode.js:Server-side JavaScriptโ€ process in Processes tab Right click on process and click on End task option from pop up as shown in below image: enter image description here

Hope this would work!!

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.