+ Start a Discussion
Raviteja_KRaviteja_K 

Issue with SFDX: Authorize an Org

Hello All,
I am trying to Create a Hello World Lightning Web Component as mentioned in the URL below.
Hello World Lightning Web Component (https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/create-a-hello-world-lightning-web-component?trail_id=build-lightning-web-components)
But in VS code I am getting below output and did some analysis but unable to risolve it please help me how can I proceed further.

VS code output:
Starting SFDX: Authorize an Org

09:42:18.175 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.
09:42:23.367 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://login.salesforce.com --setdefaultusername ended with exit code 1
------------------------------Sometimes below error is coming-------------------
use a custom connected app and update OauthLocalPort in the sfdx-project.json file

Thanks in Advance :)
Parteek Goyal 3Parteek Goyal 3
Hi Raviteja_K,

You have to kill the port 1717 process. please follow below link, this may help you.
http://www.callstack.in/tech/blog/windows-kill-process-by-port-number-157#close-overlay

Please let me know in case of any issue.

Thanks,
Parteek
Raviteja_KRaviteja_K
Thank you @Parteek for responding quickly on my Question.
Post performing the steps mentioned in the given URL got output as mentioned below.

Starting SFDX: Authorize an Org
11:33:00.980 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://login.salesforce.com --setdefaultusername
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=b5d7ace33b21^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=2tdcYoPQwS4SytSxyyCWZPvXbjG-cJG42iesCBF4DDo' ] }
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=b5d7ace33b21^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=2tdcYoPQwS4SytSxyyCWZPvXbjG-cJG42iesCBF4DDo' ] }
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=b5d7ace33b21^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=2tdcYoPQwS4SytSxyyCWZPvXbjG-cJG42iesCBF4DDo' ] }
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=b5d7ace33b21^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=2tdcYoPQwS4SytSxyyCWZPvXbjG-cJG42iesCBF4DDo' ] }

Please suggest me on this.
Thanks in Advance :)
Parteek Goyal 3Parteek Goyal 3
Hi Raviteja_K,

Did you check enviorment variables for your system. You must add below enviorment variables.

JAVA, Salesforce CLI, VS Code, System32

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,
Parteek Goyal
Raviteja_KRaviteja_K

Thank you Prateek for your respone.

Issue is Resolved after setting Proxy settings.

Michael Salesforce 8Michael Salesforce 8
@Raviteja_K, Can you please explain the steps, how you set the proxy setting and what values we need to put in address and port. I am not able to resolve this issue. I am facing the same problem as yours. 
Teo PopaTeo Popa
@Ravietja_K and @Michael Salesforce 8, Were you two able to resolve the issue? I'm getting the same error and trying to understand what "Issue is Resolved after setting Proxy Settings" exactly means? @Ravietja_K can you provide steps for how you did this?
Teo PopaTeo Popa
@Ravietja_K I found this answer on another stackexchange question(https://salesforce.stackexchange.com/questions/191088/salesforcedx-behind-a-corporate-proxy-that-intercepts-https-traffic), can you confirm if this is what you did also in your environment variables to resolve the issue?

"​​​​​​Identified the issue. I had set the environment variable HTTP_PROXY in the Environment Variables section of my windows System Properties to
http://webproxyaddress:8080/
instead of
http://user:pwd@webproxyaddress:8080/
I had set these correctly everywhere else, but since I was on a windows machine I somehow missed going back and checking my systems environment variable. Turns out this is a really important step!"
Hariom KankerwalHariom Kankerwal
@Ravietja_K  I am not able to resolve this issue. I am facing the same problem as yours.
i am using local machine , i don't things it will be proxy setting issue.
Kindly suggest 
Teo PopaTeo Popa
Discovered for us the issue also was not having C:\Windows\System32 in our environment variables path so suggest trying this as well.
kumar 393kumar 393
@Ravietja_K and @Teo Popa I am having the same issue and I have set the path C:\Windows\System32 in our environment variables and I had set the environment variable HTTP_PROXY in the Environment Variables section of my windows System Properties to
http://webproxyaddress:8080/. The issue is still not resolved. I keep getting the same error as below.

Starting SFDX: Authorize an Org
11:35:26.773 sfdx force:auth:web:login --setalias vscodeOrg --instanceurl https://login.salesforce.com --setdefaultusername
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=46c1108c2830^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=KaSmJ2QYMtuO06KLUUM1B_3c5FZaUDADD6ugrRaF0h4' ] }
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=46c1108c2830^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=KaSmJ2QYMtuO06KLUUM1B_3c5FZaUDADD6ugrRaF0h4' ] }
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=46c1108c2830^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=KaSmJ2QYMtuO06KLUUM1B_3c5FZaUDADD6ugrRaF0h4' ] }
{ 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',
     'https://login.salesforce.com//services/oauth2/authorize?response_type=code^&client_id=PlatformCLI^&redirect_uri=http%3A%2F%2Flocalhost%3A1717%2FOauthRedirect^&state=46c1108c2830^&prompt=login^&scope=refresh_token%20api%20web^&code_challenge=KaSmJ2QYMtuO06KLUUM1B_3c5FZaUDADD6ugrRaF0h4' ] }

I have been struggling from few days on this issue.
Any help is appreciated.
Thanks in advance.