MT4 error 6: No connection with trade server (ERR_NO_CONNECTION)

The terminal had no working link to the broker around the time of the request. It may have executed; check before any retry.

6ERR_NO_CONNECTION
Check firstSafe to retry?
MaybeCould it have executed?

What it means

You see this code in GetLastError() in MQL4, after a trade function fails on the server side.

MT4 couldn't talk to the trade server. If the link was already down, nothing was sent. If it dropped during the request, the broker may have acted.

From your code you can't tell which of the two happened.

Common causes

  • A network outage or a poor connection.
  • The broker's server restarting.
  • A terminal that lost its login, for example after a password change.

How to fix it

  • Check IsConnected() before sending.
  • After error 6, wait for the connection, then look for your order in open orders and history.
  • Send again only if there is no trace of it.

Example in MQL4:

// After an unclear answer: did the order open anyway?
int FindMine(const string sym, const int magic, const string tag)
{
   for(int i = OrdersTotal() - 1; i >= 0; i--)
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)
         && OrderSymbol() == sym && OrderMagicNumber() == magic
         && OrderComment() == tag)
         return OrderTicket();
   return -1;
}

int ticket = OrderSend(Symbol(), OP_BUY, 0.10, Ask, 3, 0, 0, "job-4711", 4711);
if(ticket < 0)
{
   int err = GetLastError();
   if(err == ERR_NO_CONNECTION)
   {
      Sleep(2000);
      RefreshRates();
      int found = FindMine(Symbol(), 4711, "job-4711");
      Print(found > 0 ? "It opened: ticket " + IntegerToString(found) : "No trace yet; check history before resending");
   }
}

Is it safe to retry?

Only after the connection is back and you have checked the account.

Could the order have executed?

Maybe, if the link dropped during the request.

How Tickwire handles it

Tickwire treats it like MT5 10031: it never sends new exposure again, looks for the effect and reports applied, rejected or unknown. The MT4 code stays in the message. See idempotency.

All MetaTrader error codes

One API for MT4 and MT5

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