nginx resource_error ai_generated true

client_body_temp_file_write() failed (28: No space left on device) while reading client request body

ID: nginx/client-body-temp-file-write-failed

Also available as: JSON · Markdown · 中文
95%Fix Rate
92%Confidence
1Evidence
2024-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx-1.24.0 active
nginx-1.25.3 active
nginx-1.26.0 active

Root Cause

The filesystem partition where nginx stores temporary client body files (usually /var/lib/nginx/tmp or /tmp) is full.

generic

中文

nginx 存储客户端请求体临时文件的分区(通常是 /var/lib/nginx/tmp 或 /tmp)已满。

Official Documentation

https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_temp_path

Workarounds

  1. 95% success Free up space on the partition or move the temp directory to a partition with more space. Example: sudo du -sh /var/lib/nginx/tmp sudo rm -rf /var/lib/nginx/tmp/* # Or change path in nginx.conf: client_body_temp_path /data/nginx/tmp 1 2;
    Free up space on the partition or move the temp directory to a partition with more space. Example:
    sudo du -sh /var/lib/nginx/tmp
    sudo rm -rf /var/lib/nginx/tmp/*
    # Or change path in nginx.conf:
    client_body_temp_path /data/nginx/tmp 1 2;
  2. 90% success Increase the partition size if using LVM or cloud storage. For example, on AWS EBS, extend the volume and resize the filesystem.
    Increase the partition size if using LVM or cloud storage. For example, on AWS EBS, extend the volume and resize the filesystem.

中文步骤

  1. Free up space on the partition or move the temp directory to a partition with more space. Example:
    sudo du -sh /var/lib/nginx/tmp
    sudo rm -rf /var/lib/nginx/tmp/*
    # Or change path in nginx.conf:
    client_body_temp_path /data/nginx/tmp 1 2;
  2. Increase the partition size if using LVM or cloud storage. For example, on AWS EBS, extend the volume and resize the filesystem.

Dead Ends

Common approaches that don't work:

  1. 60% fail

    The buffer only delays temp file creation; large requests will still hit disk.

  2. 50% fail

    It forces all body data into memory, which can cause OOM for large uploads.

  3. 80% fail

    Nginx will fail to create the temp directory and return a permission denied error.