# 写入客户端请求体临时文件失败（28：设备上无剩余空间）

- **ID:** `nginx/client-body-temp-file-write-failed`
- **领域:** nginx
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| nginx-1.24.0 | active | — | — |
| nginx-1.25.3 | active | — | — |
| nginx-1.26.0 | active | — | — |

## 解决方案

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.
   ```

## 无效尝试

- **** — The buffer only delays temp file creation; large requests will still hit disk. (60% 失败率)
- **** — It forces all body data into memory, which can cause OOM for large uploads. (50% 失败率)
- **** — Nginx will fail to create the temp directory and return a permission denied error. (80% 失败率)
