nginx: [error] open() ‘/usr/local/var/run/’ failed (2: No such file or directory) — Technolize Your Future

Sandeep Agrawal
2 min readAug 16, 2020
  • What is the Error:
    nginx [error] open() “/usr/local/var/run/” failed (2: No such file or directory)
  • Why is this Error:
    This error occurs if there is no nginx directory or no file found in the system.
  • Reason for this Error:
    The reason is that every time you reboot the system, gets deleted automatically.

Solution 1

The first solution is to run commands to generate the missing file

  • Provide a specific config file path to Nginx command so that will be created if the file is not present.
sudo nginx -c /usr/local/etc/nginx/nginx.conf # -c stands configuration file.
  • Reload nginx:
nginx -s reload

Solution 2

The second solution is to change the path of in the configuration file.

  • Open the Nginx config file using the below command.
sudo vim /usr/local/etc/nginx/nginx.conf
  • Search for “;” and you should find it as commented code like below so just uncomment that line and save the file. (You can change the location from ‘/logs’ to something else as if you want)
# pid logs/; // remove # to uncomment this line.
  • Run the same two commands as mentioned in the above ‘solution 1’ section to load the config file and start Nginx.
sudo nginx -c /usr/local/etc/nginx/nginx.conf
nginx -s reload


Hope this helps resolve your nginx issue.

Originally published at on August 16, 2020.