function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lakshya KanchanLakshya Kanchan 

Issue in running the same bat file twice

Hi

I have a bat file which contains SFDX CLI commands to fulfill my business scenarios.

I have a business scenario wherein the bat file is opened twice at the same time.

I am getting the "Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file." error in the 2nd cmd window that is opened.

I checked through the articles and found that we need to kill the 1st cmd window to open the 2nd cmd window.

Is there a way to make the sfdx cli chose any open port if one port is busy?

Regards,
Lakshya
SubratSubrat (Salesforce Developers) 
Hello Lakshya ,

You can configure the SFDX CLI to use a random available port instead of a fixed port. To do this, you need to update the "OauthLocalPort" property in the sfdx-project.json file.

You can set this property to "0" which will instruct the SFDX CLI to choose a random available port when starting the OAuth server. Here's an example:
 
{
    "packageDirectories": [
        {
            "path": "force-app",
            "default": true
        }
    ],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "50.0",
    "oauthLocalPort": "0"
}


Once you've made this change, you should be able to open multiple instances of the bat file without encountering the "Kill the process running on port 1717" error.

References -> https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm

https://developer.salesforce.com/forums/?id=9062I000000IDtcQAG



If it helps please mark this as Best Answer.
Thank you.