Restarting Appium Server could improve various server freezing issues and may improve execution time

Several threads on Appium’s official forum and in some other discussion platforms , its is evident that a large number of users facing the issue of Appium server freezing which is boosting test execution time significantly. This issue is blocking when iOS 8 device is concerned.


What it means – Freezing?

Well, We might be having a test suite which contains automation scripts that runs over a time period of several hours. If Appium server goes unresponsive in between the test run , creating a situation where script execution is freezed at some point which does not give the indication of either test failure or pass , in fact user has no clue if script is still running or it got failed.

What We assumed:

There is a possibility that Appium server after getting a large instruction sets to execute , eventually gets unresponsive and becomes idle by not responding to client side or not executing the commands at server side.

What could be an effective solution?

If its all about – freezing after several minutes/hours of test run, what if we restart the server in between. A fresh session, a new session Id and each session has to deal with a set of commands, which is light weight.

Of course, I am not saying to keep a watch and restart the server in between manually 😛

How to restart Appium server programatically during run time?

In this case using GUI version of Appium won’t help. We need to run Appium from source and execute commands required for start-stop operation from code itself.

Steps to run Appium from source:

1. Install Node.JS (
2. Clone Appium – git clone
3.  Use following commands (provide password where ever asked)
cd appium
sudo ./bin/authorize-ios.js # for ios only
node .

To execute command (node .) , which starts appium from JAVA code , we will be needing a JAVA library – Apache Commons exec

If we are using Maven following dependency can be added else the necessary jar file can be added to the build path:

How to do it in MAC OSX:

To Start Appium from Java Code:public static void start()
CommandLine command = new CommandLine(“/usr/local/bin/node”);
command.addArgument(“/Users/user_name/appium”,false);  //Replace user_name with the computer account name
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
Executor executor = new DefaultExecutor();
catch(Exception e)
APPLICATION_LOGS.error(“Error While Starting Appium Server: “+e.getMessage());

To Stop Appium Server from Java Code:

public static void stop() 
    CommandLine command = new CommandLine(“/usr/bin/killall”);
    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();    
    Executor executor = new DefaultExecutor();
    executor.execute(command, resultHandler);
catch(Throwable e)
    APPLICATION_LOGS.error(“Error While Stopping Appium Server: “+e.getMessage());


On Windows we can do it in similar fashion by replacing the paths to various executables and replacing with the Windows equivalent command to stop a process.

This way , we can start/stop Appium server in between the test run , according to the implementation of the automation script.

Happy Testing 🙂

  • vasu

    Really useful article

  • Zetendra

    But for starting appium from Code, we need pass all the data like app-path, iOS version , No Reset… Where do we need to give in the code.. Could you please help me in starting the appium server from the code…. Thank you

    • Abhishek Swain

      Hi Zetendra

      You can pass appium server arguments/flags just like other commands passed.

      For example:
      To Pass Custom IP:

      For a complete list of server flags/arguments please refer to this link:


  • Mohammed Faizan

    Hey Abhishek, could you please write a detailed blog on the steps for using appium on a real ios device (Ipod touch). I’ve tried a lot, but could not run the test on a physical device. Thanks in Advance