[SOLVED !] How can I start appium server programatically in parallel?

I am running latest appium (installed globally with npm) I want to start and stop appium in parallel,
But it’s looks hard to implement, since capabilities are strings and port is int, maybe someone can help?

I am using java code and using AppiumServiceBuilder,


It’s pretty hard to explain, I spend a lot of time to make it work.
To start appium i’m using this method where I pass the port from the testng.xml.
You also need to specify a different system port for each instance.
You should find some threads here, explaining everything.

capabilities.setCapability(AndroidMobileCapabilityType.SYSTEM_PORT, systemPort);

public void startServer(int appiumPort) {
	final AppiumServiceBuilder builder;
	builder = new AppiumServiceBuilder();
	builder.withArgument(GeneralServerFlag.LOG_LEVEL, "error");
	service = AppiumDriverLocalService.buildService(builder);
	this.appiumServiceUrl = service.getUrl().toString();
	logger.info("Appium Service started at " + this.appiumServiceUrl);

Thanks for the answer, so I need to define “port” for each instance in test.ng xml and also system port?
Can you explain about sytem port?


check this

Hi, thanks for your response, it’s to complicated, I have windows, maven, not a mac, And this is too. Hard to. Implement…

I tried everything, it doesnt work,
Someone has a sample code for activate appium server programatically in parallel?

Check this out, there is a list with tutorials and sample frameworks

Doesn’t work, already try it,

I need to Activate the appium server from java code for a few devices and that’s seems to be an issue…

That’s so hard?
I hoped that by using udid it can help… Port is int and annotations are Stringa, seems that I’m stuck…

Any help will be appriciate

@Abush why not to start Appium in Java as in command line using any executer (tons in Java). If you can start appium with command: “appium” in console/terminal, it should not be a problem.

Hi @Aleksei,

I need also to monitor that the appium service is up/down and to do add extra flags like - - relaxed security and so on, Is it possible? To start appium server in parallel from cmd and also to monitor each server o
If he’s running or not?

why you need to monitor? just start X appium servers with ERROR! logs (works better), some UNIQUE port each and any other flags you need before tests. And close servers after.

Thanks, I will try and update.

Still no luck… I have tried so many methods

we do not know anything about your “no luck”. we need more info to help you. how you tried? why it does not help you?

After a lot of trying I succeed to activate appium (JAVA) pragmatically in parallel,
This is my code that works now:

public DesiredCapabilities cap = new DesiredCapabilities();
static String Appium_Node_Path = “C:\Program Files\nodejs\node.exe”;//That is my patch, change it to your path
static String Appium_JS_Path = “C:\node_modules\appium\build\lib\main.js”; //That is my patch, change it to your path

cap.setCapability(“deviceName”, deviceName);
cap.setCapability(“udid”, udid);
cap.setCapability(“url”, url);

    cap.setCapability("appPackage", "your package");
    cap.setCapability("appActivity", "your activity");
    cap.setCapability(MobileCapabilityType.NO_RESET, true);

  AppiumDriverLocalService service;
   service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().
            usingPort(4723).usingDriverExecutable(new File(Appium_Node_Path)).
            withAppiumJS(new File(Appium_JS_Path))
            .withArgument(GeneralServerFlag.LOG_LEVEL, "error")
    Log.info("Appium started ......");
    driver = new AndroidDriver<MobileElement>(new URL(""), cap); 

And make another one just like that with 1 change: URL: with diff port,
also using testng.xml for each device,

Works great !

I am working now on framework that connecting the devices in the network automatically, kill the appium server automatically, start the appium server automatically with no limit of devices, ios + android,
Also found a simple way to kill the appium server port before starting the server.

I am using minimum code(java) and progress is very good, if someone wants to join then please reply,


Where need to change the URL and port here for each device? did you mean here -> new URL(" ? or Using port?