I am using Python AppiumService to start my appium server
from appium.webdriver.appium_service import AppiumService
service = AppiumService()
args = [
"--address", "127.0.0.1", # this works
#"--address", "0.0.0.0", # this works on cmd line, but not in script. Why?
"--port", "4723",
"--log-no-colors",
"--base-path", '/wd/hub'
]
print(f"starting cmd = appium {' '.join(args)}")
service.start(args=args)
print(f"service.is_running={service.is_running}")
print(f"service.is_listening={service.is_listening}")
service.stop()
If I use the localhost address 127.0.0.1 as listening address, it works.
C:\Users\...> python myscript.py
starting cmd = appium --address 127.0.0.1 --port 4723 --log-no-colors --base-path /wd/hub
service.is_running=True
service.is_listening=True
But if I use the wildcard address 0.0.0.0, which should be the default address, it doesn't work
C:\Users\...> python myscript.py
starting cmd = appium --address 0.0.0.0 --port 4723 --log-no-colors --base-path /wd/hub
Traceback (most recent call last):
File "c:\Users\...\test_appiumService.py", line 14, in <module>
service.start(args=args)
File "c:\users\...\site-packages\appium\webdriver\appium_service.py", line 222, in start
raise AppiumServiceError(error_msg)
appium.webdriver.appium_service.AppiumServiceError: Appium server has started but is not listening on /wd/hub/status within 60000ms timeout. Make sure proper values have been provided to --base-path, --address and --port process arguments.
The 0.0.0.0 address works fine on command line
c:\Users\...>appium --address 0.0.0.0 --port 4723 --log-no-colors --base-path /wd/hub
[Appium] Welcome to Appium v1.22.3
[Appium] Non-default server args:
[Appium] logNoColors: true
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
Environment:
Windows 10 latest patch,
Python 3.10,
Appium server 1.22.3,
Appium-Python-Client 2.7.1
I've noticed the same when setting up my test project. I'm guessing the reason could be that 0.0.0.0 cannot be pinged and for some reason starting it via code requires a ping, while starting the server yourself does not. But it's a guess, I'm really not sure.