ERROR: Running multiple appiums on one server

I want to run multiple appium on one server

But it gets the following error in the ipython terminal:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Device emulator-5556 was not in the list of connected devices

The way I work I open multiple terminals on a Mac with the following specs:

appium -p 4723 --base-path “/wd/hub”
appium -p 4724 --base-path “/wd/hub”
appium -p 4725 --base-path “/wd/hub”

And then I try to open my driver (Android application) in the devices as follows:

sysPort = DF_Manage_Devices_and_Accounts(read_or_write='read').loc[AVD_Name, 'sysPort']
Udid = DF_Manage_Devices_and_Accounts(read_or_write='read').loc[AVD_Name, 'Udid-(DeviceId)']  
 
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['deviceName'] = 'Android'
desired_caps['automationName'] = 'UiAutomator2'
desired_caps['udid'] = Udid
desired_caps['app'] = (PathFileAPK+'Instagram_x86_64.apk')
desired_caps['appPackage'] = "com.instagram.android"
desired_caps['appActivity'] = 'com.instagram.android.activity.MainTabActivity'
desired_caps['noReset'] = True
global driver
driver = webdriver.Remote(f'http://127.0.0.1:{sysPort}/wd/hub', desired_caps)

sysPort is a variable that I try to control ports from within the Excel file to give each device its own port

And the «error log» I get on my appium server is as follows:

Last login: Fri Feb  2 09:01:06 on ttys007

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
Amirzs-MacBook-Pro:~ amir$ appium -p 4725 --base-path "/wd/hub"
[Appium] Welcome to Appium v2.2.1
[Appium] Non-default server args:
[Appium] {
[Appium]   basePath: '/wd/hub',
[Appium]   port: 4725
[Appium] }
[Appium] Attempting to load driver xcuitest...
[Appium] Requiring driver at /Users/amir/.appium/node_modules/appium-xcuitest-driver
[Appium] Attempting to load driver uiautomator2...
[Appium] Requiring driver at /Users/amir/.appium/node_modules/appium-uiautomator2-driver
[Appium] Appium REST http interface listener started on http://0.0.0.0:4725/wd/hub
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium] 	http://127.0.0.1:4725/wd/hub (only accessible from the same host)
[Appium] 	http://192.168.43.94:4725/wd/hub
[Appium] 	http://10.8.0.213:4725/wd/hub
[Appium] Available drivers:
[Appium]   - [email protected] (automationName 'XCUITest')
[Appium]   - [email protected] (automationName 'UiAutomator2')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
[HTTP] Request idempotency key: 8ad589a4-17f1-4a3c-baf6-378dd14377e1
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"Android","appium:deviceName":"Android","appium:automationName":"UiAutomator2","appium:udid":"emulator-5556","appium:app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appium:appPackage":"com.instagram.android","appium:appActivity":"com.instagram.android.activity.MainTabActivity","appium:noReset":true}]},"desiredCapabilities":{"platformName":"Android","deviceName":"Android","automationName":"UiAutomator2","udid":"emulator-5556","app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appPackage":"com.instagram.android","appActivity":"com.instagram.android.activity.MainTabActivity","noReset":true}}
[AppiumDriver@3cf0] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","deviceName":"Android","automationName":"UiAutomator2","udid":"emulator-5556","app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appPackage":"com.instagram.android","appActivity":"com.instagram.android.activity.MainTabActivity","noReset":true},null,{"firstMatch":[{"platformName":"Android","appium:deviceName":"Android","appium:automationName":"UiAutomator2","appium:udid":"emulator-5556","appium:app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appium:appPackage":"com.instagram.android","appium:appActivity":"com.instagram.android.activity.MainTabActivity","appium:noReset":true}]}]
[AppiumDriver@3cf0] Event 'newSessionRequested' logged at 1706852794557 (09:16:34 GMT+0330 (Iran Standard Time))
[Appium] Attempting to find matching driver for automationName 'UiAutomator2' and platformName 'Android'
[Appium] The 'uiautomator2' driver was installed and matched caps.
[Appium] Will require it at /Users/amir/.appium/node_modules/appium-uiautomator2-driver
[Appium] Requiring driver at /Users/amir/.appium/node_modules/appium-uiautomator2-driver
[AppiumDriver@3cf0] Appium v2.2.1 creating new AndroidUiautomator2Driver (v2.29.4) session
[AppiumDriver@3cf0] Checking BaseDriver versions for Appium and AndroidUiautomator2Driver
[AppiumDriver@3cf0] Appium's BaseDriver version is 9.4.1
[AppiumDriver@3cf0] AndroidUiautomator2Driver's BaseDriver version is 9.4.1
[AndroidUiautomator2Driver@b67f] Creating session with W3C capabilities: {
[AndroidUiautomator2Driver@b67f]   "alwaysMatch": {
[AndroidUiautomator2Driver@b67f]     "platformName": "Android",
[AndroidUiautomator2Driver@b67f]     "appium:deviceName": "Android",
[AndroidUiautomator2Driver@b67f]     "appium:automationName": "UiAutomator2",
[AndroidUiautomator2Driver@b67f]     "appium:udid": "emulator-5556",
[AndroidUiautomator2Driver@b67f]     "appium:app": "/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk",
[AndroidUiautomator2Driver@b67f]     "appium:appPackage": "com.instagram.android",
[AndroidUiautomator2Driver@b67f]     "appium:appActivity": "com.instagram.android.activity.MainTabActivity",
[AndroidUiautomator2Driver@b67f]     "appium:noReset": true
[AndroidUiautomator2Driver@b67f]   },
[AndroidUiautomator2Driver@b67f]   "firstMatch": [
[AndroidUiautomator2Driver@b67f]     {}
[AndroidUiautomator2Driver@b67f]   ]
[AndroidUiautomator2Driver@b67f] }
[AndroidUiautomator2Driver@b67f] The following provided capabilities were not recognized by this driver:
[AndroidUiautomator2Driver@b67f]   deviceName
[AndroidUiautomator2Driver@b67f (d973bd2f)] Session created with session id: d973bd2f-60d2-4ed2-8fd9-fab82789ac68
[BaseDriver] Using local app '/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk'
[AndroidUiautomator2Driver@b67f (d973bd2f)] Checking whether app is actually present
[ADB] Found 1 'build-tools' folders under '/Users/amir/Library/Android/sdk' (newest first):
[ADB]     /Users/amir/Library/Android/sdk/build-tools/34.0.0
[ADB] Using 'adb' from '/Users/amir/Library/Android/sdk/platform-tools/adb'
[ADB] Running '/Users/amir/Library/Android/sdk/platform-tools/adb -P 5037 start-server'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices
[ADB] Connected devices: [{"udid":"emulator-5554","state":"device"}]
[AndroidDriver] Device emulator-5556 was not in the list of connected devices
[AndroidUiautomator2Driver@b67f (d973bd2f)] Deleting UiAutomator2 session
[AppiumDriver@3cf0] Event 'newSessionStarted' logged at 1706852795695 (09:16:35 GMT+0330 (Iran Standard Time))
[AppiumDriver@3cf0] Encountered internal error running command: Error: Device emulator-5556 was not in the list of connected devices
[AppiumDriver@3cf0]     at Object.wrappedLogger.errorAndThrow (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/node_modules/@appium/support/lib/logging.js:115:34)
[AppiumDriver@3cf0]     at Object.getDeviceInfoFromCaps (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/android-helpers.js:241:16)
[AppiumDriver@3cf0]     at AndroidUiautomator2Driver.startUiAutomator2Session (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/lib/driver.js:352:26)
[AppiumDriver@3cf0]     at AndroidUiautomator2Driver.createSession (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/lib/driver.js:241:7)
[AppiumDriver@3cf0]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:374:35)
[HTTP] <-- POST /wd/hub/session 500 1273 ms - 622
[HTTP] 
[HTTP] Request idempotency key: 2962cad4-ba6a-4e6f-9cde-e356ed21aee5
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"Android","appium:deviceName":"Android","appium:automationName":"UiAutomator2","appium:udid":"emulator-5556","appium:app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appium:appPackage":"com.instagram.android","appium:appActivity":"com.instagram.android.activity.MainTabActivity","appium:noReset":true}]},"desiredCapabilities":{"platformName":"Android","deviceName":"Android","automationName":"UiAutomator2","udid":"emulator-5556","app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appPackage":"com.instagram.android","appActivity":"com.instagram.android.activity.MainTabActivity","noReset":true}}
[AppiumDriver@3cf0] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","deviceName":"Android","automationName":"UiAutomator2","udid":"emulator-5556","app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appPackage":"com.instagram.android","appActivity":"com.instagram.android.activity.MainTabActivity","noReset":true},null,{"firstMatch":[{"platformName":"Android","appium:deviceName":"Android","appium:automationName":"UiAutomator2","appium:udid":"emulator-5556","appium:app":"/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk","appium:appPackage":"com.instagram.android","appium:appActivity":"com.instagram.android.activity.MainTabActivity","appium:noReset":true}]}]
[AppiumDriver@3cf0] Event 'newSessionRequested' logged at 1706852802576 (09:16:42 GMT+0330 (Iran Standard Time))
[Appium] Attempting to find matching driver for automationName 'UiAutomator2' and platformName 'Android'
[Appium] The 'uiautomator2' driver was installed and matched caps.
[Appium] Will require it at /Users/amir/.appium/node_modules/appium-uiautomator2-driver
[Appium] Requiring driver at /Users/amir/.appium/node_modules/appium-uiautomator2-driver
[AppiumDriver@3cf0] Appium v2.2.1 creating new AndroidUiautomator2Driver (v2.29.4) session
[AppiumDriver@3cf0] Checking BaseDriver versions for Appium and AndroidUiautomator2Driver
[AppiumDriver@3cf0] Appium's BaseDriver version is 9.4.1
[AppiumDriver@3cf0] AndroidUiautomator2Driver's BaseDriver version is 9.4.1
[AndroidUiautomator2Driver@7a82] Creating session with W3C capabilities: {
[AndroidUiautomator2Driver@7a82]   "alwaysMatch": {
[AndroidUiautomator2Driver@7a82]     "platformName": "Android",
[AndroidUiautomator2Driver@7a82]     "appium:deviceName": "Android",
[AndroidUiautomator2Driver@7a82]     "appium:automationName": "UiAutomator2",
[AndroidUiautomator2Driver@7a82]     "appium:udid": "emulator-5556",
[AndroidUiautomator2Driver@7a82]     "appium:app": "/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk",
[AndroidUiautomator2Driver@7a82]     "appium:appPackage": "com.instagram.android",
[AndroidUiautomator2Driver@7a82]     "appium:appActivity": "com.instagram.android.activity.MainTabActivity",
[AndroidUiautomator2Driver@7a82]     "appium:noReset": true
[AndroidUiautomator2Driver@7a82]   },
[AndroidUiautomator2Driver@7a82]   "firstMatch": [
[AndroidUiautomator2Driver@7a82]     {}
[AndroidUiautomator2Driver@7a82]   ]
[AndroidUiautomator2Driver@7a82] }
[AndroidUiautomator2Driver@7a82] The following provided capabilities were not recognized by this driver:
[AndroidUiautomator2Driver@7a82]   deviceName
[AndroidUiautomator2Driver@7a82 (4b389133)] Session created with session id: 4b389133-5c35-4543-92fb-eb35d7f05798
[BaseDriver] Using local app '/Users/amir/Documents/07-Affiliate/Robots-Instagram-with-Appium/FileAPK/Instagram_x86_64.apk'
[AndroidUiautomator2Driver@7a82 (4b389133)] Checking whether app is actually present
[ADB] Using 'adb' from '/Users/amir/Library/Android/sdk/platform-tools/adb'
[ADB] Running '/Users/amir/Library/Android/sdk/platform-tools/adb -P 5037 start-server'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices
[ADB] Connected devices: [{"udid":"emulator-5554","state":"device"}]
[AndroidDriver] Device emulator-5556 was not in the list of connected devices
[AndroidUiautomator2Driver@7a82 (4b389133)] Deleting UiAutomator2 session
[AppiumDriver@3cf0] Event 'newSessionStarted' logged at 1706852803320 (09:16:43 GMT+0330 (Iran Standard Time))
[AppiumDriver@3cf0] Encountered internal error running command: Error: Device emulator-5556 was not in the list of connected devices
[AppiumDriver@3cf0]     at Object.wrappedLogger.errorAndThrow (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/node_modules/@appium/support/lib/logging.js:115:34)
[AppiumDriver@3cf0]     at Object.getDeviceInfoFromCaps (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/android-helpers.js:241:16)
[AppiumDriver@3cf0]     at AndroidUiautomator2Driver.startUiAutomator2Session (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/lib/driver.js:352:26)
[AppiumDriver@3cf0]     at AndroidUiautomator2Driver.createSession (/Users/amir/.appium/node_modules/appium-uiautomator2-driver/lib/driver.js:241:7)
[AppiumDriver@3cf0]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:374:35)
[HTTP] <-- POST /wd/hub/session 500 753 ms - 622

In the end, it shows me the error 500 below, what is the reason, I feel that the problem is from here!!!?

[HTTP] <-- POST /wd/hub/session 500 753 ms - 622

I would say the issue is quite obvious