Skip to content
Home » nginx: [error] open() ‘/usr/local/var/run/’ failed (2: No such file or directory)

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


About the error

  • 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

First solution is to run command to generate 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

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

I hope this helps you to resolve your Nginx issue.


Related Posts

Visit to find more related topics.

Happy Coding!!!

Leave a Reply

Your email address will not be published. Required fields are marked *