# MetaTrader 5 Python internal error codes

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/mt5/internal-errors, 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.

Every negative code mt5.last_error() returns in the MetaTrader5 Python package, what each one means and what to do about it. One page rather than a dozen near identical ones.

- Last reviewed: 2026-09-25

Unverified in part: carried over from an earlier version of this site. The links below are the sources it was written from, but its statements have not been re-read at source since the date shown, so check anything you rely on.

## How to read these codes

The MetaTrader5 Python package does not raise an exception when a call fails. It returns None or False, and the reason sits in mt5.last_error(), which gives a code and a short description. The codes below are the negative ones: they describe the package talking to the MetaTrader 5 terminal on your own computer, rather than anything a broker did. Codes from 10000 upward are trade server return codes and are decoded on their own pages.

A first check after any failure is worth writing once and reusing: call mt5.last_error(), print both the code and the description, and stop rather than retrying blindly. Most of the codes below are cured by the same three habits: start the terminal and log in before the script runs, keep the MetaTrader5 package and the terminal at versions that match, and ask for smaller ranges of history.

## The codes

- `-1``RES_E_FAIL`A generic failure. The docs call it “generic fail”.What to do Check terminal is running and logged in, then retry.Single code page for RES_E_FAIL no page of its own on this build
- `-2``RES_E_INVALID_PARAMS`The function was called with invalid arguments. The docs call it “invalid arguments/parameters”.What to do Check argument types and values against the function docs.Single code page for RES_E_INVALID_PARAMS no page of its own on this build
- `-3``RES_E_NO_MEMORY`The terminal ran out of memory. The docs call it “no memory condition”.What to do Request smaller ranges of data.Single code page for RES_E_NO_MEMORY no page of its own on this build
- `-4``RES_E_NOT_FOUND`No history was found for the request. The docs call it “no history”.What to do Check the symbol is in Market Watch and the date range has data.Single code page for RES_E_NOT_FOUND no page of its own on this build
- `-5``RES_E_INVALID_VERSION`Version mismatch. The docs call it “invalid version”.What to do Update the MetaTrader5 package and terminal.Single code page for RES_E_INVALID_VERSION no page of its own on this build
- `-6``RES_E_AUTH_FAILED`Login to the trade account failed. The docs call it “authorization failed”.What to do Check login, password and server name.Single code page for RES_E_AUTH_FAILED no page of its own on this build
- `-7``RES_E_UNSUPPORTED`The method is not supported. The docs call it “unsupported method”.What to do Use a supported function or update the package.Single code page for RES_E_UNSUPPORTED no page of its own on this build
- `-10000``RES_E_INTERNAL_FAIL`General failure talking to the terminal. The docs call it “internal IPC general error”.What to do Restart the terminal and call initialize() again.Single code page for RES_E_INTERNAL_FAIL no page of its own on this build
- `-10001``RES_E_INTERNAL_FAIL_SEND`Sending to the terminal failed. The docs call it “internal IPC send failed”.What to do Restart the terminal and reinitialise.Single code page for RES_E_INTERNAL_FAIL_SEND no page of its own on this build
- `-10002``RES_E_INTERNAL_FAIL_RECEIVE`Receiving from the terminal failed. The docs call it “internal IPC recv failed”.What to do Restart the terminal and reinitialise.Single code page for RES_E_INTERNAL_FAIL_RECEIVE no page of its own on this build
- `-10003``RES_E_INTERNAL_FAIL_INIT`IPC initialisation failed; the docs also list RES_E_INTERNAL_FAIL_CONNECT (internal IPC no ipc) under -10003. The docs call it “internal IPC initialization fail”.What to do Check the terminal path passed to initialize() and that the terminal can start.[Single code page for RES_E_INTERNAL_FAIL_INIT](https://openbrokerapi.com/errors/mt5/minus-10003-res-e-internal-fail-init)
- `-10005``RES_E_INTERNAL_FAIL_TIMEOUT`The terminal did not respond in time. The docs call it “internal timeout”.What to do Increase the timeout in initialize() or check the terminal is responsive.Single code page for RES_E_INTERNAL_FAIL_TIMEOUT no page of its own on this build

Source [MQL5 docs: last_error (Python)](https://www.mql5.com/en/docs/python_metatrader5/mt5lasterror_py), last checked 25 Sep 2026

## More MetaTrader 5 pages

- [All MetaTrader 5 error codes](https://openbrokerapi.com/errors/mt5)Internal codes and trade server return codes
- mt5.initialize()Connect Python to the terminal, and the codes it returns when it fails
- Every MetaTrader5 Python functionSignatures, returns and the traps to know
- [MetaTrader 5 API guide](https://openbrokerapi.com/platforms/metatrader-5)Auth, limits and the brokers that offer it

## More on the MetaTrader 5 API

- [MetaTrader 5 API quickstart](https://openbrokerapi.com/platforms/metatrader-5/quickstart): From credentials to a first call on a demo account, step by step.
- [MetaTrader 5 API error codes](https://openbrokerapi.com/errors/mt5): 311 decoded, each with what it means, and the fix where the source gives one.
- [MetaTrader 5 functions](https://openbrokerapi.com/platforms/metatrader-5/functions): 78 documented, each with its signature, arguments, return value and source.
- [MetaTrader 5 API page](https://openbrokerapi.com/platforms/metatrader-5): The full record: access, authentication, limits and the source for each.
- [Claude with MetaTrader 5: a safe, read-first setup](https://openbrokerapi.com/guides/claude-mt5): Guide
- [MetaTrader 5 for Python: which platforms does it run on?](https://openbrokerapi.com/guides/metatrader-5-python-platforms): Guide
- [MT5 trade history to a spreadsheet with Python](https://openbrokerapi.com/guides/mt5-trade-history-to-a-spreadsheet): 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: MetaTrader 5 Python internal error codes. Broker API Hub, https://openbrokerapi.com/errors/mt5/internal-errors, newest check 2026-09-25.

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.
