+ Start a Discussion
Parteek Goyal 3Parteek Goyal 3 

SFDX: Authorize an Org failed to run

Hi All,

I am tring to authorize an org on visual studio code but when I am trying authorize it, I am getting the below error.

SFDX: Authorize an Org failed to run
Try this:
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.
19:31:13.241 sfdx force:auth:web:login --setalias VSCodePlayground --instanceurl https://login.salesforce.com --setdefaultusername ended with exit code 1

I have Killed the Process on port 1717 and tried it again then I am not getting any error but it is running for infinite time. 

Please help.

Thanks,
Parteek
Khan AnasKhan Anas (Salesforce Developers) 
Hi Parteek,

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
Ajay K DubediAjay K Dubedi
Hi Parteek,

Yes, there is already one process in running so you have to first kill that process after you can authorize your Org.
You should follow this command in your VS code terminal:

Example: taskkill /PID 13872 /F

For kill VScode process
netstat -ano | findstr :8084

You can also install Task Kill tool from VS code marketplace
- Open up the prompt (F1 \ Ctrl+Shift+P \ CMD+Shift+P) and select: "Task Kill: Kill an active network
  task (by port number)" or simply hit Ctrl + Del (numpad_decimal).
- Type in the port number of the process you want to kill.
- Hit enter.

You can follow this link for more help:
https://marketplace.visualstudio.com/items?itemName=Shynet.vscode-taskkill

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi
Parteek Goyal 3Parteek Goyal 3

Hi Anas/Ajay,

I have tried this, but still facing the same issue.

Thanks,
Parteek

SAKTHIVEL MSAKTHIVEL M

same issue to me, even i tried all https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_troubleshoot_cancel_auth.htm

then not worked for me, so i reinstalled the vsc and installed the plugin and its worked perfectly. but not sure this as the solution, but worth to retry to install and check it.

Thanks
 
Swapnagandha HawaldarSwapnagandha Hawaldar
Ajay,

netstat and taskkill commands helped me sort this issue out. Thanks a lot!
Swapna
Mohammed IliyasMohammed Iliyas
Hi guys,
1.Press Ctrl+Alt+Delete, then click Task Manager.
2.Select the Process tab.
3.Find the process named Node.
4.Select the process that you want to end, and then click End Process.

Hope this will work.
Vidyut DevamVidyut Devam
Hi Ilyas,

I have tried killing the process named node. Now when i tried to authorise the dev hub then this command runs for uncertain time and doesnt open up browser window asking for allow or deny options. 
Any help will be appreciated.

Parteek,
Are you able to get conquer this challenge? if yes then please give hints.

Regards
Vidyut
Hakim Upadhyay 45Hakim Upadhyay 45
Hey Vidyut,

is your problem resolved, I am facing the same issue. It is a endless process, after clicking that Node process
kumar 393kumar 393
Hi All,

I am having an 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.
hrushikesh vazehrushikesh vaze
SFDX: Authorize an Org failed to run:

If you are trying to Authorizing an Org, but you are getting an error OR if it keeps loading. 

Resolve it in 2 Steps: 

1. Open Task Manager -> Details -> Delete the process with name 'Node.exe' 
2. Set Microsoft Edge as your default browser. 

#HappyToHelp
Thanks, 
Hrushikesh 

 
Jenie Anne Cabreros 4Jenie Anne Cabreros 4
it really works! thank you
 
Anusha Dommeti 2Anusha Dommeti 2
@hrushikesh vaze , Thank you so much it worked .
sandhya rani 105sandhya rani 105
@
hrushikesh vaze...,node.exe is coming while  trying to Authorizing an Org if i kill the node.exe file . Authorize an Org failing if am doing same thing also plz help me on this
PARAG BHORPARAG BHOR
Bro I am also having the same to same issue, how did you resolve it. I am sick of this problem from past 4 days still no progress. Please help me 
Test cistestTest cistest
I am facing the same issue, please help me.

sfdx force:auth:web:login --setalias ml_09_11_2020 --instanceurl https://login.salesforce.com --setdefaultusername
 ended with exit code 1
sfdx force:auth:web:login --setalias ml_09_11_2020 --instanceurl https://login.salesforce.com --setdefaultusername
ERROR running force:auth:web:login:  spawn UNKNOWN
sunetra parnaiksunetra parnaik
i just deleted the VS code in the task manager and reopened the VS Code app and then clicked again on Authorize Org it worked for me .
sunetra parnaiksunetra parnaik
@test cistest
if you are getting ended with exit code1, it means there is a lightning component in your dev org which exists with teh same name thats why you get the errror. you can delete it from your source org and then re depoy it. It work work.
Hun LowHun Low
Hi All

I had authorize an org working and then somehow it stopped working. Though it did complain about the port, after turning it off and killing the PID,
I still had the port issue, turned out it was not the fix.

It worked at home but not at work (which it used to).
 
Realized our wonderful IT department had put an network protection tool that sniff out and certain blocks URL logins from your PC. Worked out IT put in force point and it stopped working. Had to get them to allow traffic for all saleforce site. Find out first if your IT network people has done something, especially for very large organisation.

Also I notice another thing if I tried to "Retrieve Source org" the code and config, if the data is saved to a network drive it just hangs there trying to retrieve the data. Create your "Project with Manifest" in your local drive and you will have better luck with "Retrieve Source org".  IT network  engineers sure can cause alot of issues without realising it.
Felipe Melo 2Felipe Melo 2
Hi,
if you've a admin profile, on your org, go to settings>users>click in your user and roll down. 
In :
Connected Apps do OAuth, revoke all Salesforce CLI apps with count equals 0.
Try again on VSCode and if it work give a like here.