# Interactive Brokers API error: WinError 10038

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/errors/ibkr/winerror-10038, written from the same records as that page.

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.

The error, as text you can copy:

```
WinError 10038
```

- HTTP status: None recorded for this error
- API: [Interactive Brokers](https://openbrokerapi.com/brokers/ibkr)
- Status: verified. Source: [interactivebrokers.github.io](https://interactivebrokers.github.io/tws-api/message_codes.html), checked 2026-10-09.

## What does WinError 10038 mean on the Interactive Brokers API?

Interactive Brokers lists the TWS API client error WinError 10038 with the text "An operation was attempted on something that is not a socket." (the vendor's wording). Listed among the client errors. The vendor says the socket connection was closed improperly, and that this is typical for Python clients.

## No fix in the source

The vendor's page gives no remedy of its own. It points to a Stack Overflow discussion of the error.

That is all the source says, so this page does not invent a fix. General guidance: [the other errors with no HTTP status recorded recorded for Interactive Brokers](https://openbrokerapi.com/errors/ibkr#no-http-status), the [error lookup](https://openbrokerapi.com/tools/error-lookup) for the exact text of the reply you received.

## More on the Interactive Brokers API

- [All Interactive Brokers API error codes](https://openbrokerapi.com/errors/ibkr)
- [Interactive Brokers API quickstart](https://openbrokerapi.com/brokers/ibkr/quickstart): From credentials to a first call on a demo account, step by step.
- [Interactive Brokers API error codes](https://openbrokerapi.com/errors/ibkr): 511 decoded, each with what it means, and the fix where the source gives one.
- [Interactive Brokers API endpoints](https://openbrokerapi.com/brokers/ibkr/endpoints): 23 documented, each with its method, path, parameters and source.
- [Interactive Brokers API page](https://openbrokerapi.com/brokers/ibkr): The full record: access, authentication, limits and the source for each.
- [Get your Interactive Brokers trade history into a spreadsheet](https://openbrokerapi.com/guides/ibkr-trade-history): Guide
- [IBKR API without TWS: headless IB Gateway options](https://openbrokerapi.com/guides/ibkr-headless-gateway): Guide
- [The three Interactive Brokers REST front doors compared](https://openbrokerapi.com/guides/ibkr-rest-front-doors): Guide
- [Interactive Brokers MCP servers, compared](https://openbrokerapi.com/guides/interactive-brokers-mcp-servers): Guide

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: Interactive Brokers API error: WinError 10038. Broker API Hub, https://openbrokerapi.com/errors/ibkr/winerror-10038, newest check 2026-10-09.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
