Skip to main content
InQuantWeTrust logo

Common error lookup

Search IBKR, API, and Python errors

Use this lookup to map recurring error codes and Python exceptions to concrete diagnostics. Treat each result as a technical starting point: verify your local TWS or Gateway settings, package environment, and exact request payload.

Search and filters

Results

15 matching entries

Review setup wizard →
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

IBKRSafety1100

Connectivity between IBKR and TWS has been lost

Typical symptoms

  • Connectivity lost message appears
  • Market data or order status updates stop
  • The session may reconnect later

Likely causes

  • Network interruption
  • IBKR system reset window
  • Local workstation sleep or unstable connection

Checks

  • Record the timestamp and surrounding 1101 or 1102 messages
  • Confirm whether data subscriptions were restored
  • Avoid assuming orders or account state are current

Resolution path

  • Pause automation until connectivity is restored and state is reconciled
  • After reconnect, refresh account, positions, open orders, and active subscriptions

Related terms: 1101, 1102, network, reconnect, system reset

IBKRSetup502

Couldn't connect to TWS or IB Gateway

Typical symptoms

  • IBKR API reports that it cannot connect
  • Client code times out or disconnects during startup

Likely causes

  • Wrong host or port
  • Trusted IP restrictions block the connection
  • The desktop API listener is disabled

Checks

  • Check the socket port and paper/live environment
  • Review trusted IP settings
  • Inspect the TWS or Gateway API log for rejected clients

Resolution path

  • Use a local, read-only verification script first
  • Keep trusted IPs narrow and explicitly allow the workstation that runs the script

Related terms: could not connect, TWS, Gateway, trusted IP, paper, live

IBKRData162

Historical market data service returned an error

Typical symptoms

  • Historical data request fails
  • The message mentions pacing, permissions, HMDS, or no data
  • Large batches fail intermittently

Likely causes

  • Pacing limits
  • No data for the requested instrument or duration
  • Missing permissions or unsupported bar size

Checks

  • Reduce batch size
  • Record durationStr, barSizeSetting, whatToShow, RTH flag, and endDateTime
  • Retry one contract manually before scaling

Resolution path

  • Throttle historical requests and cache successful results
  • Make requests explicit and small enough to diagnose

Related terms: HMDS, pacing, historical, barSizeSetting, durationStr, reqHistoricalData

IBKRData10197

No market data during competing live session

Typical symptoms

  • Market data works in one session but not another
  • The message mentions a competing live session

Likely causes

  • Another TWS, Gateway, mobile, or web session is consuming live data
  • The paper session is sharing live data permissions with a live login

Checks

  • Review every active IBKR login
  • Decide which session should own live data
  • Test delayed data to separate entitlement from session contention

Resolution path

  • Close competing sessions or route data requests through the intended active session
  • Design research tools to tolerate delayed or unavailable live data

Related terms: competing live session, market data, paper, live, entitlement

IBKRData200

No security definition has been found for the request

Typical symptoms

  • Contract lookup fails
  • Historical or market data request returns no contract
  • The symbol is ambiguous

Likely causes

  • Missing exchange, currency, primary exchange, expiry, strike, or multiplier
  • The symbol maps to multiple instruments
  • The contract is expired or unavailable

Checks

  • Qualify the contract before requesting data
  • Add primaryExchange for stocks when needed
  • Verify futures/options expiry and multiplier

Resolution path

  • Build a fully specified contract and inspect the qualified conId
  • Log contract fields with the request so future failures are reproducible

Related terms: contract, conId, qualifyContracts, primaryExchange, ambiguous

PythonRuntimeRuntimeError: This event loop is already running

Notebook or async code is already running an event loop

Typical symptoms

  • RuntimeError about an event loop
  • Async examples fail in Jupyter
  • Synchronous helper code works in a script but not a notebook

Likely causes

  • Jupyter already owns the event loop
  • The code mixes blocking and async APIs
  • A helper starts a nested loop

Checks

  • Identify whether the code is running in Jupyter, IPython, or a plain script
  • Use one async style consistently
  • Avoid starting nested event loops

Resolution path

  • Use notebook-compatible async patterns or the package helper intended for notebooks
  • Keep script examples and notebook examples separate in documentation

Related terms: asyncio, Jupyter, IPython, await, nest_asyncio, ib_insync

PythonSetupModuleNotFoundError

Python cannot import ib_insync or ib_async

Typical symptoms

  • No module named ib_insync
  • No module named ib_async
  • The import works in one terminal but not another

Likely causes

  • The package is installed in a different environment
  • The notebook kernel does not match the terminal interpreter
  • The virtual environment is not active

Checks

  • Print sys.executable in the failing process
  • Run python -m pip show for the package in that same interpreter
  • Confirm the notebook kernel path

Resolution path

  • Install dependencies with the interpreter that runs the code
  • Use a project virtual environment and document activation steps

Related terms: import, pip, venv, kernel, environment, ib_async

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

PythonDataTypeError: can't compare offset-naive and offset-aware datetimes

Python datetime values mix timezone-aware and naive timestamps

Typical symptoms

  • Datetime comparison fails
  • pandas filters fail after joining data sources
  • Backtest windows shift unexpectedly

Likely causes

  • Some timestamps include timezone information and others do not
  • IBKR bars, CSV files, and local timestamps were normalized differently

Checks

  • Inspect timezone metadata before merging
  • Record exchange timezone and bar-close convention
  • Verify daylight-saving transitions in sample data

Resolution path

  • Normalize timestamps deliberately at ingestion
  • Keep a documented convention such as UTC internally and display time zones only at the edge

Related terms: datetime, timezone, UTC, pandas, tz_localize, tz_convert

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

PythonData

Request succeeds but the resulting DataFrame is empty

Typical symptoms

  • No exception is raised
  • The DataFrame has zero rows
  • Downstream calculations produce NaN or empty output

Likely causes

  • The request returned no bars or positions
  • The code filtered all rows
  • The contract, date range, or permissions do not match available data

Checks

  • Inspect the raw API response before building the DataFrame
  • Log row counts after every filter
  • Test a known liquid symbol and a short time range

Resolution path

  • Handle empty data as a first-class branch
  • Fail fast with a clear diagnostic before calculations or order-related logic

Related terms: pandas, DataFrame, empty, NaN, filter, historical data

IBKRData354

Requested market data is not subscribed

Typical symptoms

  • Live market data request is rejected
  • Ticker values are delayed, frozen, or missing
  • Permissions differ between paper and live sessions

Likely causes

  • The account lacks the required market data subscription
  • The request uses live data where delayed data is expected
  • Paper account entitlement differs from live account entitlement

Checks

  • Confirm subscriptions in Account Management
  • Test delayed data type where appropriate
  • Document whether paper or live data is being requested

Resolution path

  • Subscribe to the required data or explicitly request delayed data for educational workflows
  • Do not treat missing data as a trading signal

Related terms: market data, subscription, delayed, entitlement, reqMktData

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

IBKRRuntime1300

TWS socket port was reset

Typical symptoms

  • The API reports a socket port reset
  • Existing clients disconnect
  • New connections require a different port

Likely causes

  • The API socket port changed in TWS settings
  • TWS restarted with updated configuration

Checks

  • Open API settings and read the active socket port
  • Compare the script configuration to the desktop setting

Resolution path

  • Update the client port and reconnect deliberately
  • Store environment-specific ports in configuration instead of hard-coding them across scripts

Related terms: port reset, socket, TWS settings, configuration

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.