ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:4723

In github actions hosted runner macoOS
I run my webdriverio + browserstack appium test

I have installed the following
“appium”: “^2.1.3”,
“appium-xcuitest-driver”: “^5.7.0”,
“appium-uiautomator2-driver”: “^2.31.3”,

In my workflow yml file

  • name: Run the test
    run: |
    npm uninstall -g appium
    npm install -g [email protected]
    appium --version
    npm -g install npm@6
    appium &

        npm install -g npm@latest
        brew install nvm
        source ~/.nvm/nvm.sh
        nvm install 18
        nvm use 18   
        yarn test:execute:${{inputs.platform}}:bs.ipa | tee /tmp/log || true
    

however, the log shows
connection issue for appium

2023-10-16T13:51:01.077Z ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:4723

141[0-0] at ClientRequest. (file:///Users/runner/work/sh-usermanagement-native-poc/sh-usermanagement-native-poc/node_modules/got/dist/source/core/index.js:790:107)

142[0-0] at Object.onceWrapper (node:events:632:26)

143[0-0] at ClientRequest.emit (node:events:529:35)

144[0-0] at ClientRequest.emit (node:domain:489:12)

145[0-0] at Socket.socketErrorListener (node:_http_client:501:9)

146[0-0] at Socket.emit (node:events:517:28)

147[0-0] at Socket.emit (node:domain:489:12)

148[0-0] at emitErrorNT (node:internal/streams/destroy:151:8)

149[0-0] at emitErrorCloseNT (node:internal/streams/destroy:116:3)

150[0-0] at processTicksAndRejections (node:internal/process/task_queues:82:21)

151[0-0] at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)

152[0-0] 2023-10-16T13:51:01.078Z ERROR @wdio/runner: Error: Failed to create session.

153[0-0] Unable to connect to “http://127.0.0.1:4723/”, make sure browser driver is running on that address.

154[0-0] It seems like the service failed to start or is rejecting any connections.