iOS issue: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:8100

I have a scenario to wifi Off and On. I tried many ways but everytime I am getting the following same error. It is working inconsistent. I tried 5 ways around but half of the cases passing and rest failing due the following exception. Please let me know any issue with Appium 1.22.3 related this issue. Let me know if you need any other details. Due to this exception I am unable to complete my testing. Thanks advance for your help
Used the following versions
Appium 1.22.3, Xcode 14.2, WebDriverAgent 4.10.0, Java 1.8, eclipse, node 16.9.1, npm 7.21.1.
I tried in other Mac with following details but got same issue
Appium 2.1.3, Xcode 15, WebDriverAgent 5.10.0, Java 1.8, eclipse, node 20.8.0, npm 10.1.0
Script 1:
DragAndDrop using JavaScriptExecutor from top right corner
int startX = 0;
int endX = 0;
int startY = 0;
int endY = 0;
startY = (int) (25);
endY = (int) (500);
startX = (int) (350);
JavascriptExecutor js = (JavascriptExecutor) driver;
Map<String, Object> params = new HashMap<>();
params.put(“duration”, 1.0);
params.put(“fromX”, startX);
params.put(“fromY”, startY);
params.put(“toX”, startX);
params.put(“toY”, endY);
js.executeScript(“mobile: dragFromToForDuration”, params);
Issue:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:8100 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘C02FD8QYMD6M’, ip: ‘fe80:0:0:0:1c66:aa38:b1dd:5ee7%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘13.5.1’, java.version: ‘1.8.0_381’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {acceptInsecureCerts: true, appActivity: .MainActivity, autoAcceptAlerts: true, autoDismissAlerts: true, autoGrantPermissions: true, autoWebview: true, automationName: XCUITest, browserName: , bundleId: com.abc.mobileapp, databaseEnabled: false, deviceName: IPhoneAuto, fullReset: false, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 300, noReset: false, platform: MAC, platformName: iOS, platformVersion: 16.1, systemAlertsDelayEnabled: true, takesScreenshot: true, udid: 00008020-XXXXXXXXXXX, webStorageEnabled: false}
Session ID: cc21efd4-193e-4661-a7a5-8a9426e239a0
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:489)
at com.qa.pages.BasePage.switchOffOnWifi(BasePage.java:7559)
at com.qa.pages.BasePage.offline(BasePage.java:771)

Script2: Using touchAction drag from top right corner to off or on wifi
int startX = 0;
int endX = 0;
int startY = 0;
int endY = 0;
startY = (int) (25);
endY = (int) (500);
startX = (int) (350);
TouchAction touchAction = new TouchAction(driver);
touchAction.longPress(PointOption.point(startX, startY)).moveTo(PointOption.point(startX, endY)).release().perform();
Issue:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:8100 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘C02FD8QYMD6M’, ip: ‘fe80:0:0:0:1c66:aa38:b1dd:5ee7%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘13.5.1’, java.version: ‘1.8.0_381’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {acceptInsecureCerts: true, appActivity: .MainActivity, autoAcceptAlerts: true, autoDismissAlerts: true, autoGrantPermissions: true, autoWebview: true, automationName: XCUITest, browserName: , bundleId: com.abc.mobileapp, databaseEnabled: false, deviceName: IPhoneAuto, fullReset: false, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 300, noReset: false, platform: MAC, platformName: iOS, platformVersion: 16.1, systemAlertsDelayEnabled: true, takesScreenshot: true, udid: 00008020-XXXXXXXXXXXX, webStorageEnabled: false}
Session ID: b59a520a-b8ca-4dce-94ea-af185e2d30b8
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at io.appium.java_client.PerformsTouchActions.performTouchAction(PerformsTouchActions.java:41)
at io.appium.java_client.TouchAction.perform(TouchAction.java:187)
at com.qa.pages.BasePage.switchOffOnWifi(BasePage.java:7548)
at com.qa.pages.BasePage.offline(BasePage.java:767)

Scrpt3: opening preference page to off or on wifi
Map<String, Object> args = new HashMap<>();
args.put(“bundleId”, “com.apple.Preferences”);
driver.executeScript(“mobile: launchApp”, args);
Issue
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:8100 (WARNING: The server did not provide any stacktrace information)