Broker API HubMenu

IBKR TimeoutError() in ib_async after login

Two reports on the ib_async issue tracker describe IB Gateway accepting a connection and closing it straight after login, one surfacing as TimeoutError(). Both were read through the GitHub API on 30 November 2026, and both have since been closed with an answer from the maintainers. What the answers say to check.

Independent and unofficialChecked For: Python users of ib_async whose IB Gateway connection drops straight after a successful login

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Steps

  1. The first report: TimeoutError() straight after Connected

    Issue 143, opened on 25 April 2025 with ib_async 1.0.3 against IB Gateway 10.30.1 on macOS, shows the log lines Connecting and Connected followed by TimeoutError(). A first reply on 7 May 2025 suggested removing the timeout argument from ib.connect. The maintainer's answer of 23 October 2026 says the Gateway accepted the socket and then closed it right after the API start message, which means the Gateway itself refused the session, and lists the usual causes: a clientId still held by a stale session, so restart the Gateway or try another id; the Gateway waiting for you to accept the incoming connection; the client's IP address missing from Trusted IPs; or the Gateway still logging in or restarting. The issue is closed.

    github.comchecked

  2. The second report: a script that connects and then ends

    Issue 169, opened on 12 August 2025 on Windows 11 with ib_async 2.0.1 and IB Gateway 10.30, describes a connection that drops immediately after a successful handshake, with TWS working and the Gateway not. Replies over the following year suggested checking the Gateway's API settings (Enable ActiveX and Socket Clients, trusted IPs) and the Gateway log. The maintainer's answer of 23 October 2026 is different from the first issue's: the script posted connects, prints and then ends, so Python exits and the connection closes, which IB Gateway shows as a disconnect right after login. To keep the session open, keep the program running: call ib.run() at the end, or do the work with ib.sleep between requests. The issue is closed.

    github.comchecked

  3. What to check, in the order the answers give

    First, whether your script has anything to do after connect: a script that only connects and prints will exit, and the Gateway reports that exit as a dropped connection. Second, the Gateway's API settings and whether the client's address is in Trusted IPs, or whether the Gateway is waiting for you to accept the incoming connection in its own window. Third, the clientId: restart the Gateway or use another id if a stale session still holds it. Fourth, timing: a Gateway that is still logging in or restarting refuses sessions. ib_async's README asks for Python 3.10 or later and installs with pip install ib_async. None of this has been reproduced by this site; it is what the maintainers wrote on the two threads.

    github.comchecked

Sources

Sections