nautechsystems/nautilus_trader · error · anyhow::Error
Cannot submit order: execution client not connected
Error message
Cannot submit order: execution client not connected
What it means
`submit_order` refuses to submit an order when the dYdX execution client's connection check (`is_connected()`) fails. This is a deliberate guard so orders are never sent over a dead WebSocket/gRPC link where they would be silently lost.
Source
Thrown at crates/adapters/dydx/src/execution/mod.rs:1279
if self.core.is_stopped() {
log::warn!("dYdX execution client not started");
return Ok(());
}
log::info!("Stopping dYdX execution client");
self.session_tasks.begin_shutdown();
self.begin_pending_shutdown();
self.ws_client.begin_shutdown();
self.core.set_stopped();
self.core.set_disconnected();
Ok(())
}
fn submit_order(&self, cmd: SubmitOrder) -> anyhow::Result<()> {
if !self.is_connected() {
let reason = "Cannot submit order: execution client not connected";
log::error!("{reason}");
anyhow::bail!(reason);
}
let current_block = self.block_time_monitor.current_block_height();
let order = self.core.cache().try_order_owned(&cmd.client_order_id)?;
let client_order_id = order.client_order_id();
let instrument_id = order.instrument_id();
let strategy_id = order.strategy_id();
if current_block == 0 {
let reason = "Block height not initialized";
log::warn!("Cannot submit order {client_order_id}: {reason}");
self.emitter.emit_order_denied(&order, reason);
return Ok(());
}
if order.is_closed() {
log::warn!("Cannot submit closed order {client_order_id}");View on GitHub (pinned to 18893faf8b)
Solutions
- Wait for the client to report connected before submitting (subscribe to connection state / retry after connect)
- Check network connectivity and dYdX endpoint status
- Restart the adapter/node to re-establish the connection
- Verify the adapter is running in live mode — a disconnected execution client will never accept orders
Example fix
// before
client.submit_order(cmd)?;
// after
if client.is_connected() {
client.submit_order(cmd)?;
} else {
log::warn!("skipping submit, client disconnected");
} Defensive patterns
Strategy: validation
Validate before calling
if !client.is_connected() { return Err(anyhow!("client not connected")); } Try / catch
match client.submit_order(cmd) {
Err(e) if e.to_string().contains("not connected") => reconnect_and_retry(),
Err(e) => return Err(e),
Ok(_) => {}
} Prevention
- Gate order submission on a connected-state flag/event
- Subscribe to adapter connection state changes
- Add a readiness wait after client startup before trading
When it happens
Trigger: Calling `submit_order` (directly or via `submit_order_list`) while the client is disconnected — e.g. before `connect()` completes, after a dropped WebSocket, or during a reconnect window.
Common situations: Strategy starts before the adapter finishes connecting; network outage drops the live connection; adapter was never started in a live/trading context.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- Cannot submit order list: execution client not connected
- Cannot cancel order: not connected
- Cannot cancel orders: not connected
- handler command channel closed: {e}
- Take profit limit order missing limit price
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/f7094b30fe7cd458.
Report an issue: GitHub.