MT5 Python error -10004: No IPC connection (RES_E_INTERNAL_FAIL_CONNECT)
A package function was called with no live connection to the terminal, often before initialize() or after shutdown().
What it means
You see this code in mt5.last_error() in Python, after a package call returns None or False.
The package has no open channel to a terminal. Any call other than initialize() fails with "No IPC connection".
The official table prints this code as -10003 by mistake. The value the package returns is -10004.
Common causes
- Calling functions before
mt5.initialize()succeeded. - Calling them after
mt5.shutdown(). - A terminal that closed while your script kept running.
- Using the package from a new process without initializing there.
How to fix it
- Check the return value of
mt5.initialize()and stop if it isFalse. - Initialize in every process that uses the package.
- Reconnect when you see -10004 in a long running script.
Example in Python:
import MetaTrader5 as mt5
def ensure_connected():
if mt5.terminal_info() is None: # no connection
if not mt5.initialize():
raise RuntimeError(mt5.last_error())
ensure_connected()
print(mt5.account_info().login) Is it safe to retry?
Yes, after a successful initialize().
Could the order have executed?
No. Without a connection the call never reached the terminal.
How Tickwire handles it
With Tickwire your code calls a REST API from any operating system. You don't install this package or keep a terminal running yourself. See the MT5 Python API page.
Related codes
- MT5 Python error -10003: IPC initialize failed (RES_E_INTERNAL_FAIL_INIT)
- MT5 Python error -10001: IPC send failed (RES_E_INTERNAL_FAIL_SEND)
- MT5 Python error -10000: IPC internal error (RES_E_INTERNAL_FAIL)
Related MT5 Python functions
- mt5.initialize() in MetaTrader5 Python: connect Python to the terminal
- mt5.login() in MetaTrader5 Python: log in to a trading account
- mt5.shutdown() in MetaTrader5 Python: close the link to the terminal
- mt5.version() in MetaTrader5 Python: read the terminal's version and build
- mt5.last_error() in MetaTrader5 Python: find out why the last call failed
- mt5.account_info() in MetaTrader5 Python: read balance, equity and margin
- mt5.terminal_info() in MetaTrader5 Python: check the terminal and its broker link
- mt5.symbols_total() in MetaTrader5 Python: count every symbol the terminal knows
- mt5.symbols_get() in MetaTrader5 Python: list symbols, with an optional filter
- mt5.orders_total() in MetaTrader5 Python: count pending orders
- mt5.orders_get() in MetaTrader5 Python: read pending orders
- mt5.positions_total() in MetaTrader5 Python: count open positions
- mt5.positions_get() in MetaTrader5 Python: read open positions
- mt5.history_orders_total() in MetaTrader5 Python: count orders in history
- mt5.history_deals_total() in MetaTrader5 Python: count deals in history
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.