elastic/elasticsearch · warning · RuntimeException

Failed to send message (READY=1) to systemd socket: {}

Error message

Failed to send message (READY=1) to systemd socket: {}

What it means

Thrown as a RuntimeException (notify_ready uses warnOnError=false) when libc.send() returns -1 after successfully connecting to the systemd NOTIFY_SOCKET. The error includes the strerror(errno) detail. This means the socket was opened and connected but the datagram could not be written, typically due to the socket buffer being full or the socket being closed by systemd.

Source

Thrown at libs/native/src/main/java/org/elasticsearch/nativeaccess/Systemd.java:114

                    if (error != null) {
                        error.addSuppressed(e);
                        throw error;
                    } else {
                        throw e;
                    }
                }
            } else if (error != null) {
                throw error;
            }
        }
    }

    private void throwOrLog(String message, boolean warnOnError) {
        if (warnOnError) {
            logger.warn(message);
        } else {
            logger.error(message);
            throw new RuntimeException(message);
        }
    }
}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Check if the systemd service is still active: 'systemctl status <service>'.
  2. If the service was stopped during startup, this is expected; ensure startup completes before shutdown can intervene.
  3. Increase the socket buffer size if sending large notifications.
  4. Wrap notify_ready() in try-catch so startup is not blocked by a failed sd_notify.

Example fix

// before
systemd.notify_ready(); // throws RuntimeException on send failure

// after
try {
    systemd.notify_ready();
} catch (RuntimeException e) {
    logger.warn("sd_notify READY=1 failed, continuing startup", e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// No pure pre-check for send() failure; guard with try-catch instead.
// Ensure NOTIFY_SOCKET is set and the service is active before calling.

Try / catch

try {
    systemd.notify_ready();
} catch (RuntimeException e) {
    logger.warn("Failed to send READY=1 to systemd; process will continue without notification", e);
}

Prevention

When it happens

Trigger: Calling systemd.notify_ready() when the NOTIFY_SOCKET datagram socket rejects the send() call. Common when systemd has closed the socket (service already stopped) or when the kernel message buffer for the socket is exhausted.

Common situations: Service stopped by systemd while the JVM was still initializing. Race between shutdown and READY=1 notification. Socket buffer exhaustion under heavy notification load. systemd version mismatch with the socket protocol.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/ac7a45688ffa805b. Report an issue: GitHub.