{"record":{"id":"cb6cce6cdc26e60f","repo":"nginx/nginx","slug":"ngx-log-alert-cb6cce","errorCode":"NGX_LOG_ALERT","errorMessage":"recvmsg() failed","messagePattern":"recvmsg\\(\\) failed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/event/ngx_event_udp.c","lineNumber":98,"sourceCode":"            msg.msg_control = &msg_control;\n            msg.msg_controllen = sizeof(msg_control);\n\n            ngx_memzero(&msg_control, sizeof(msg_control));\n        }\n#endif\n\n        n = recvmsg(lc->fd, &msg, 0);\n\n        if (n == -1) {\n            err = ngx_socket_errno;\n\n            if (err == NGX_EAGAIN) {\n                ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, err,\n                               \"recvmsg() not ready\");\n                return;\n            }\n\n            ngx_log_error(NGX_LOG_ALERT, ev->log, err, \"recvmsg() failed\");\n\n            return;\n        }\n\n#if (NGX_HAVE_ADDRINFO_CMSG)\n        if (msg.msg_flags & (MSG_TRUNC|MSG_CTRUNC)) {\n            ngx_log_error(NGX_LOG_ALERT, ev->log, 0,\n                          \"recvmsg() truncated data\");\n            continue;\n        }\n#endif\n\n        sockaddr = msg.msg_name;\n        socklen = msg.msg_namelen;\n\n        if (socklen > (socklen_t) sizeof(ngx_sockaddr_t)) {\n            socklen = sizeof(ngx_sockaddr_t);\n        }","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/nginx/nginx/blob/3f6f7824d4e2eb1ac37dec76683d525ac0ff521c/src/event/ngx_event_udp.c#L80-L116","documentation":"recvmsg(2) on a UDP listening socket returned -1 with an errno other than EAGAIN. nginx logs it at ALERT with the errno text appended and drops this event; the listener stays healthy and processes subsequent datagrams. The errno is the key diagnostic — it names the actual kernel-level failure.","triggerScenarios":"Kernel errors during datagram receive: ENOBUFS under receive-buffer pressure on high-PPS UDP services (DNS, QUIC), ECONNREFUSED from an earlier ICMP error queued on the socket, or a socket in an abnormal state after binary upgrade inheritance.","commonSituations":"DNS or QUIC frontends under datagram floods; misbehaved NAT/containers feeding ICMP errors; sockets shared across master/worker during live upgrades.","solutions":["Read the errno on the log line first — remediation depends entirely on it","ENOBUFS / buffer pressure: raise net.core.rmem_max and net.core.rmem_default, and the per-listener rcvbuf, or shed traffic at the edge","ECONNREFUSED: find what is sending to unreachable peers from this socket (health probes to dead upstreams are the usual source)","If it recurs with the same errno, inspect with ss -uamp and strace -e trace=recvmsg on the worker"],"exampleFix":"# before\nsysctl net.core.rmem_max=212992   # default, drops under QUIC floods\n\n# after\nsysctl -w net.core.rmem_max=16777216\nsysctl -w net.core.rmem_default=1048576\n# and per-listener rcvbuf if tuned","handlingStrategy":"validation","validationCode":"# pre-flight the datagram environment\nsysctl net.core.rmem_max net.core.rmem_default\nss -uamp | grep -E 'port ${PORT}' | head","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size kernel receive buffers for peak PPS before high-traffic events","Health-check UDP targets so probes stop generating ICMP errors (ECONNREFUSED)","Log-watch the errno suffix to classify transient vs persistent failures"],"tags":["udp","recvmsg","socket","errno","buffer-pressure"],"backgroundTag":"udp-socket-error","analyzedSha":"3f6f7824d4e2eb1ac37dec76683d525ac0ff521c","analyzedAt":"2026-08-22T03:09:46.447Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}