elastic/elasticsearch · warning · UnsupportedOperationException

RLIMIT_NPROC unavailable: {}

Error message

RLIMIT_NPROC unavailable: {}

What it means

Thrown during macOS BSD sandbox setup in tryInstallExecSandbox() → initBsdSandbox(). As a secondary hardening measure (beyond seatbelt), the code calls setrlimit(RLIMIT_NPROC=7, {0, 0}) to prevent the process from forking new processes. If setrlimit returns non-zero, this error fires with strerror. RLIMIT_NPROC=7 is macOS/BSD-specific (it means something different on Linux, hence the hardcoded constant).

Source

Thrown at libs/native/src/main/java/org/elasticsearch/nativeaccess/MacNativeAccess.java:154

                MemorySegment errorPtr = errorBuf.get(ValueLayout.ADDRESS, 0);
                String message = MemorySegmentAdapter.getString(errorPtr.reinterpret(Long.MAX_VALUE), 0);
                macLibc.sandbox_free_error(errorPtr);
                throw new UnsupportedOperationException("sandbox_init(): " + message);
            }
            logger.debug("OS X seatbelt initialization successful");
        } finally {
            IOUtils.deleteFilesIgnoringExceptions(rules);
        }
    }

    private void initBsdSandbox() {
        RLimit limit = libc.newRLimit();
        limit.rlim_cur(0);
        limit.rlim_max(0);
        // not a standard limit, means something different on linux, etc!
        final int RLIMIT_NPROC = 7;
        if (libc.setrlimit(RLIMIT_NPROC, limit) != 0) {
            throw new UnsupportedOperationException("RLIMIT_NPROC unavailable: " + libc.strerror(libc.errno()));
        }

        logger.debug("BSD RLIMIT_NPROC initialization successful");
    }
}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Read the strerror in the message to identify the errno (commonly EPERM).
  2. Ensure the ES process runs with sufficient privileges to call setrlimit.
  3. Verify no child processes or excessive threads exist at the time of the call.
  4. If the RLIMIT_NPROC hardening is not required, accept the failure — the seatbelt sandbox (error 669 path) is the primary defense.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    nativeAccess.tryInstallExecSandbox();
} catch (UnsupportedOperationException e) {
    // setrlimit(RLIMIT_NPROC, 0) failed.
    logger.warn("BSD RLIMIT_NPROC sandbox unavailable: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling tryInstallExecSandbox() on macOS where libc.setrlimit(RLIMIT_NPROC, limit) returns non-zero after setting both rlim_cur and rlim_max to 0. The limit struct was allocated via libc.newRLimit().

Common situations: Insufficient privileges to set resource limits; the process has already spawned child processes or threads that conflict with RLIMIT_NPROC=0; macOS versions where RLIMIT_NPROC semantics differ; running under an existing resource-limit policy that prevents lowering NPROC.

Related errors


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