[Jenkins]: Cant connect to appium server

I’m trying to run the appium server on my local machine which is running and i get the correct output in the command prompt. However, when trying to run test through jenkins on my local machine, it gives a request timed out error.
My test runs fine locally and i even tried using a Virtual machine with oracles VM box, that was also able to connect to appium server running on my local machine.
This issue is only happening when trying to run my test script through jenkins slave.

ERROR webdriver: Request failed with status undefined due to RequestError: connect ETIMEDOUT myIP:4723 when running “http://myIP:4723/session” with method “POST” and args “{“capabilities”:{“alwaysMatch”:{“platformName”:“Android”,“appium:automationName”:“UiAutomator2”,“appium:deviceName”:“Android”},“firstMatch”:[{}]},“desiredCapabilities”:{“platformName”:“Android”,“appium:automationName”:“UiAutomator2”,“appium:deviceName”:“Android”}}”
2024-03-09T00:15:24.988Z ERROR webdriver: RequestError: connect ETIMEDOUT myIP:4723 when running

It is all depends how slave machone where running code connecting to jenkins. In some cases you need provide all paths to java, adnroid tools and so on…

To check this just execute

echo $PATH

Command and compare with result while you do in manually in terminal on same machine.

I’m not sure if path is related because I run selenium grid for a different test case through Jenkins on my local machine and it works fine. All I do is run a command to execute the test case and it connects to selenium grid which is running on my machine. Is there a way to integrate appium into the selenium grid? Or do I just have to try something else?
Just some additional context, I’m using nodejs, JavaScript to run browser testing for selenium and for appium, it’s webdriverio.