1

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

1

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 – Ashwani Kumar Apr 8 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' ] } – Ashwani Kumar Apr 8 at 18:08
1

You can configure this from the launch.json file. You want to find the "env" property and add

 "ASPNETCORE_URLS":"http://localhost:<PORT_NUMBER>"
  Adjusting from the default launch.json it should look something like this:

"env": {
  "ASPNETCORE_ENVIRONMENT": "Development",
  "ASPNETCORE_URLS":"http://localhost:5001"
 },

This way your port change will only affect your locally running application and you won't be adding debugging code to your production application

  • From where i will get launch.json file – Ashwani Kumar Apr 8 at 18:02
1

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

0

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)

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.