maestro: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9080 on iOS Simulator test run

Similarly to #595 and https://github.com/mobile-dev-inc/dadb/issues/48, this error occurs intermittently when trying to run flows with maestro test. In my local environment, this tends to happen when I have another terminal tab running maestro studio at the same time that I try to run maestro test, whether the maestro studio process is running or if the process had been closed a few seconds ago (conflicting background process?).

Maestro version 1.19.2 (installed via curl) Environment: Mac Pro M1 Max

Click to see the complete log

java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9080
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
	at xcuitest.XCTestDriverClient.runningAppId(XCTestDriverClient.kt:55)
	at ios.xctest.XCTestIOSDevice.activeAppId(XCTestIOSDevice.kt:191)
	at ios.xctest.XCTestIOSDevice.contentDescriptor(XCTestIOSDevice.kt:48)
	at ios.LocalIOSDevice.contentDescriptor(LocalIOSDevice.kt:32)
	at maestro.drivers.IOSDriver.contentDescriptor(IOSDriver.kt:175)
	at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:344)
	at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:343)
	at maestro.utils.MaestroTimer.withTimeout(MaestroTimer.kt:16)
	at maestro.Maestro.findElementWithTimeout(Maestro.kt:343)
	at maestro.orchestra.Orchestra.findElement(Orchestra.kt:646)
	at maestro.orchestra.Orchestra.findElement$default(Orchestra.kt:628)
	at maestro.orchestra.Orchestra.tapOnElement(Orchestra.kt:558)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:159)
	at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:443)
	at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:358)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:185)
	at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:443)
	at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:358)
	at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:185)
	at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:137)
	at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:91)
	at maestro.orchestra.Orchestra.runFlow$default(Orchestra.kt:72)
	at maestro.cli.runner.TestSuiteInteractor.runFlow(TestSuiteInteractor.kt:136)
	at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:67)
	at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:45)
	at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:118)
	at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:100)
	at maestro.cli.session.MaestroSessionManager.newSession(MaestroSessionManager.kt:91)
	at maestro.cli.command.TestCommand.call(TestCommand.kt:100)
	at maestro.cli.command.TestCommand.call(TestCommand.kt:39)
	at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
	at picocli.CommandLine.access$1200(CommandLine.java:145)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
	at maestro.cli.DisableAnsiMixin$Companion.executionStrategy(DisableAnsiMixin.kt:22)
	at picocli.CommandLine.execute(CommandLine.java:2058)
	at maestro.cli.AppKt.main(App.kt:122)
	Suppressed: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9080
		... 55 more
	Caused by: java.net.ConnectException: Connection refused (Connection refused)
		at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
		at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
		at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
		at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
		at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
		at java.base/java.net.Socket.connect(Socket.java:615)
		at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
		at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
		... 54 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
	at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.base/java.net.Socket.connect(Socket.java:615)
	at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
	... 54 more

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 21 (7 by maintainers)

Most upvoted comments

Hey folks, there is a confusion here. There are 2 separate issues getting discussed here which are not related to each other. The necessary fixes for both of them will be released in next versions.

  1. ConnectException what the title speaks about: That could happen if you have multiple sessions of maestro running. One of the cases being what @idrakimuhamad stated. We have a tentative fix for this one which should soon be out and we’ll keep you guys updated on that.
  2. Another one where exception line is “[Unable to obtain active app id]. (https://github.com/mobile-dev-inc/maestro/issues/646)” . For this one, ensure that your 9080 port is free before running iOS tests for now to unblock.