APIRuntime326
Client ID is already in use
Typical symptoms
- A second script cannot connect
- A notebook reconnect replaces or collides with another session
Likely causes
- Two API clients use the same clientId
- A previous process did not disconnect cleanly
- A notebook cell was rerun while the old connection remained active
Checks
- List running notebooks, scripts, services, and terminals
- Confirm each workflow has a stable unique client ID
- Disconnect stale sessions before reconnecting
Resolution path
- Assign a different client ID per process
- Call disconnect in finally blocks and stop stale processes deliberately
Related terms: clientId, duplicate client, ib_insync, notebook, session
APISetupConnectionRefusedError / WinError 10061
Python cannot open a socket to TWS or IB Gateway
Typical symptoms
- Connection refused
- No listener on 127.0.0.1
- The script fails before an IBKR client session is established
Likely causes
- TWS or IB Gateway is closed
- The configured port does not match the running paper or live session
- API socket clients are not enabled
Checks
- Confirm TWS or Gateway is logged in
- Verify the API socket port in the desktop settings
- Use 127.0.0.1 for first local tests
Resolution path
- Start the IBKR application, enable socket clients, and retry with the exact local port
- Paper defaults are commonly 7497 for TWS and 4002 for Gateway, but local settings are authoritative
Related terms: localhost, socket, port, 7497, 4002, ib.connect, connectAsync
APIRuntime504
Request sent while the IBKR client is not connected
Typical symptoms
- Not connected
- Requests fail after an apparent disconnect
- A later API call fails although startup succeeded
Likely causes
- The socket dropped
- The code did not wait for the connection to complete
- TWS or Gateway restarted
Checks
- Check isConnected before sending requests
- Review recent disconnect messages
- Confirm startup code awaits asynchronous connection calls
Resolution path
- Gate requests behind an explicit connection check
- Reconnect intentionally and resubscribe to required data after a session loss
Related terms: not connected, isConnected, disconnect, reconnect, async
APIRuntime321
Server validation error on an API request
Typical symptoms
- The request is rejected as invalid
- The error references validation or parameter constraints
Likely causes
- A required parameter is missing
- A field has the wrong type or incompatible value
- The request is valid for one asset class but not another
Checks
- Log the full request payload
- Compare parameter values to a minimal known-good request
- Check whether the contract was qualified
Resolution path
- Reduce to the smallest reproducible request, then add fields back one at a time
- Keep asset-class-specific defaults separate
Related terms: validation, parameter, request, payload, contract
Educational boundary
This lookup is for technical troubleshooting and reproducibility. It is not financial, investment, trading, tax, or legal advice. Prefer paper trading and read-only checks while diagnosing live connectivity or data issues.
Interactive Brokers, IBKR, Trader Workstation, and IB Gateway are trademarks or registered trademarks of their respective owners. InQuantWeTrust is independent and is not affiliated with, endorsed by, or sponsored by Interactive Brokers.