Could not start a new session

Hey friends,
So, I have an iPhone emulator set up with Xcode, along with simple Java code in Eclipse, and I’m running an Appium server.

import java.time.Duration;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import io.appium.java_client.ios.IOSDriver;

public class QA {
	 protected static IOSDriver driver;
	   protected static WebDriverWait wait;
	   protected static Actions actions;

	public void Test() throws InterruptedException
		DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("deviceName", "iPhone 15");
        capabilities.setCapability("browserName", "Safari");
        capabilities.setCapability("udid", "69383FAA-13AA-451D-80F1-03F765C414C9");
        capabilities.setCapability("automationName", "XCUITest");	    	
        try {
            driver = new IOSDriver(new URL(""), capabilities);
             wait = new WebDriverWait(driver, Duration.ofSeconds(10));
             actions = new Actions(driver);
        }    catch (MalformedURLException e) {

But I am getting the following error:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

I don’t understand why. Just as additional information, I am able to run the Appium inspector without any issues. However, I am unable to run only that Java file.

1 appium version?
2 how you installed appium on mac?

  1. 2.5.3
  2. By NPM command and it’s working fine

And how you start appium server in code before open driver?

1 step) Terminal> % appium than getting welcome message of Appium
[Appium] Welcome to Appium v2.5.3

Appium] Appium REST http interface listener started on
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium] (only accessible from the same host)
[Appium] Available drivers:
[Appium] - [email protected] (automationName ‘XCUITest’)
[Appium] - [email protected] (automationName ‘UiAutomator2’)
[Appium] - [email protected] (automationName ‘Safari’)

2 step) trying run Java file and getting error
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

What is interesting Appium Inspector working well but by Java it doesn’t work!

And after manual appium server start in browser you can check works?

Yep it’s working well: {“value”:{“ready”:true,“message”:“The server is ready to accept new connections”,“build”:{“version”:“2.5.3”}}}

It only means that in environment you start your url not available by some reason.
Can you try start your code in pure terminal without Eclipse?

I never did(I need to learn how I can start my code without Eclipse), once it worked fine by Eclipse

I use Maven to run Java code in terminal. You need just convert your project into maven project and fix minor thing after.

1 Like

Thanks, I going try it and will update you

You can also try to check how Eclipse starting code, environment variables and so on…

PS Just in case to try. I am starting project on MAC with url like http://localhost:6009/. Try in case replace

I tried localhost but it anyway doesn’t help, also I reinstalled Eclipse but nothing helps

Just now I also tried with Idea IDE but same result:

Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

If you do not see any logs in Appium server console (try enable debug log) while you trying to connect - problem in connection.

Thank you for support, but I solved it in next way!
I just changed Java Client in mvnrepository from last one 9.2.3 to 8.6.0 , strange it doesn’t work in versions over than 8.6.0

I did java-client version changes from 8.5.0 to 8.51., 8.6.0 … 9.2.X without code changes in driver open. Something in your code…

Solved! Thanks for the support. The issue was with my IDE; I updated the JDK to the latest version, and now it’s working well even in 9.2.2! However, I’ve noticed there’s an issue with 9.2.3.

I have the same issue but it only happens if I update the java-client lib to the 9.2.3 version. If instead of that I use the 9.2.2 it works with no problems. And all the code remains the same way.