Nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (2: No such file or directory)

I recently updated my server. I have same problem with Docker image too. Everything works fine but my site is not loading. I saw that nginx wasn’t running. So I ran nginx -t to see error and got the following on my Linux terminal

nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (2: No such file or directory)

How do I fix this and start my nginx server?

To fix Nginx: [emerg] mkdir() “/var/lib/nginx/tmp/client_body” failed (2: No such file or directory) error just create a new directory using mkdir command:

mkdir -p /var/lib/nginx/tmp/

Finally, try to test and restart/start nginx:

nginx -t
/etc/init.d/nginx start

A note about Docker Nginx users

Docker users should add the following RUN in their Dockerfile:

RUN mkdir -p /var/lib/nginx/tmp/

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki