MT5 Python error -10005: IPC timeout (RES_E_INTERNAL_FAIL_TIMEOUT)
The terminal didn't answer in time. At connect time the terminal was slow to start; during order_send the order may have executed.
What it means
You see this code in mt5.last_error() in Python, after a package call returns None or False.
The package waited for the terminal and gave up. initialize() and login() take a timeout in milliseconds, 60000 by default.
When it happens during a trade, the terminal may still have acted after Python stopped waiting.
Common causes
- A terminal that takes long to start, update or load its history.
- A slow or busy machine.
- A terminal waiting on a dialog, such as an update prompt.
How to fix it
- Start the terminal before your script, and pass a larger
timeoutif start up is slow. - Close dialogs and let updates finish.
- After a timeout on
order_send, check positions and deals before resending.
Example in Python:
import MetaTrader5 as mt5
if not mt5.initialize(timeout=120_000): # two minutes for a slow start
print(mt5.last_error()) # (-10005, ...) if it timed out Is it safe to retry?
Check first. At connect time, yes. After a trade, only once you have checked the account.
Could the order have executed?
Maybe. During order_send, maybe.
How Tickwire handles it
On Tickwire, a trade whose answer is unclear is never sent again with new exposure. A retry with the same Idempotency-Key returns the first result. See idempotency.
Related codes
- MT5 error 10012: Request canceled by timeout (TRADE_RETCODE_TIMEOUT)
- MT5 Python error -10002: IPC receive failed (RES_E_INTERNAL_FAIL_RECEIVE)
- MT5 Python error -10003: IPC initialize failed (RES_E_INTERNAL_FAIL_INIT)
Related MT5 Python functions
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.