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().

-10004RES_E_INTERNAL_FAIL_CONNECT
After a fixSafe to retry?
NoCould it 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 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 is False.
  • 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 MT5 Python functions

All MetaTrader error codes

All MetaTrader5 Python functions

One API for MT4 and MT5

Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.