elastic/elasticsearch · warning · RuntimeException

Could not open systemd socket: {}

Error message

Could not open systemd socket: {}

What it means

Thrown (or logged as a warning) by the Systemd notification module when the underlying socket() syscall fails to create a Unix datagram socket. For notify_ready() (warnOnError=false) it throws a RuntimeException after logging at ERROR level; for notify_extend_timeout() and notify_stopping() (warnOnError=true) it only logs a WARN. This indicates the OS denied socket creation, typically due to file descriptor exhaustion or permission issues.

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 process file descriptor limits with 'ulimit -n' or 'cat /proc/<pid>/limits' and raise if needed.
  2. If systemd is not managing the process, unset NOTIFY_SOCKET or skip the notify_ready() call.
  3. Investigate FD leaks: 'ls -1 /proc/<pid>/fd | wc -l'.
  4. If in a container, ensure the seccomp/AppArmor profile permits AF_UNIX socket creation.

Example fix

// before: unconditionally notifying systemd
systemd.notify_ready();

// after: guard with NOTIFY_SOCKET presence check
String notifySocket = System.getenv("NOTIFY_SOCKET");
if (notifySocket != null && !notifySocket.isEmpty()) {
    try {
        systemd.notify_ready();
    } catch (RuntimeException e) {
        logger.warn("Failed to notify systemd, continuing without sd_notify", e);
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

String notifySocket = System.getenv("NOTIFY_SOCKET");
if (notifySocket == null || notifySocket.isEmpty()) {
    // systemd is not managing this process; skip notification
    return;
}

Try / catch

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

Prevention

When it happens

Trigger: Calling systemd.notify_ready() when the process has hit its file descriptor limit (ulimit -n), or when running in a restricted environment that blocks AF_UNIX/SOCK_DGRAM socket creation. The libc.socket() call returns a negative fd.

Common situations: Running under a very low RLIMIT_NOFILE. Container with seccomp profiles blocking socket() for non-root. Running outside systemd (NOTIFY_SOCKET set but process lacks socket privileges). FD leak exhausting the descriptor table.

Related errors


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