# MetaTrader 5 API Errors & Rate Limits

> Index of every docs page as Markdown: [llms.txt](https://fxsocket.com/docs/llms.txt). All pages in one file: [llms-full.txt](https://fxsocket.com/llms-full.txt).

Source: https://fxsocket.com/docs/mt5/errors

Every error from the MetaTrader 5 API is machine-readable. Auth failures return a fixed code, and everything else (timeouts, validation, broker or MQL rejections) comes back in a uniform envelope you can branch on.

## Errors

A wrong or missing API key returns HTTP 401 with `MRPC_UNAUTHORIZED` (see [Authentication](https://fxsocket.com/docs/mt5/authentication.md)). An unknown account ID or path returns a plain 404 from the edge. Everything else (timeouts, validation failures, broker/MQL rejections) comes back in a uniform envelope with an `error` code, a `message`, and a `command_id` for log correlation:

```json
{
  "error": "MRPC_TIMEOUT",
  "message": "MarketInfo.PriceHistory timed out",
  "command_id": 19
}
```

5xx responses come in two flavors. A `500` or `504` with the envelope above means the terminal processed your request but the underlying operation failed or timed out, for example `{"error": "MRPC", "message": "CopyRates failed"}` when requesting history for a symbol your broker doesn't list (check `/symbols` for the exact spelling, suffixes included). Envelope-less 5xx responses mean the terminal itself is down or restarting, for example during the brief restart after an API-key rotation. Trading routes can briefly return 503 right after a terminal start, before the trade engine has registered.

## Rate Limits

Terminal requests are served by your own dedicated terminal, so heavy polling only slows down your own account, nobody else's. Platform routes under `/v1` are rate limited per API key: if you exceed a limit you get a `429` with a `Retry-After` header, so wait that long and retry. For live prices, positions, or account changes, prefer the [WebSocket streams](https://fxsocket.com/docs/mt5/websocket.md) over polling: you get pushed updates without burning round-trips.

## Related

- [Authentication](https://fxsocket.com/docs/mt5/authentication.md)
- [Trading](https://fxsocket.com/docs/mt5/trading.md)
- [WebSocket Streams](https://fxsocket.com/docs/mt5/websocket.md)
