Windows: Odd problem starting Appium Server programmatically via VS/dotnet: "the service starting has been expired" [Solved]

Hello, I’m having an odd problem attempting to start Appium Server 2.X programmatically via VS/dotnet in Windows (11).

The reason I say it’s odd, is that I have no problems starting it via Java or via PowerShell.

I’ve installed Appium via npm i --location=global appium
It works fine and I can run appium without any issue.

Additionally in my Java framework - this works fine:
server = AppiumDriverLocalService.buildDefaultService();

In the PowerShell CLI this also works fine:
node.exe C:\Users\<<my_user>>\AppData\Roaming\npm\node_modules\appium\build\lib\main.js --port "4723" --address ""

However, via my Visual Studio test framework (with the required NuGet packages (incl Appium.WebDriver 4.4.5)), this is not working:

var builder = new AppiumServiceBuilder();
var service = builder.Build();

In that, service.Start(); eventually times out with:

OpenQA.Selenium.Appium.Service.Exceptions.AppiumServerHasNotBeenStartedLocallyException: 'The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: "C:\Users\<<my_user>>\AppData\Roaming\npm\node_modules\appium\build\lib\main.js" --port "4723" --address "". Time 120000 ms for the service starting has been expired!'

Those file directories/locations are all correct so I’m honestly stumped as to why it’s timing out. If I do a get-process node in PowerShell can see a node process is started, but it never properly starts the server.

I’ve tried specifying the file locations as builder args but 1. it didn’t help, and 2. the error is showing the correct locations anyway.

Any ideas?

Found a solution just in case anyone else comes across this.

After adding logging:

    var service = builder
        .WithLogFile(new FileInfo(@"C:\Users\<<my_user>>\appium_log.txt"))

Saw that it was saying: No route found for /wd/hub/status

So fix was: .AddArguments(new KeyValuePair<string, string>("--base-path", "/wd/hub"))


        var builder = new AppiumServiceBuilder();
        var service = builder
            .WithArguments(new OptionCollector()
            .AddArguments(new KeyValuePair<string, string>("--base-path", "/wd/hub")))
1 Like

Should have asked you for a log. Thanks for posting the solution.