Nginx Errors & How To Solve

I – 403 forbidden error at Nginx

nginx 403 error

Many times you will face a 403 Forbidden error using Nginx webserver, and also most times, it is not related to Nginx itself. 403 error means you don’t have permission to access that part of the web. This error can be caused by many reasons, and here we will study this reasons one by one.

Wrong directory permissions:

One of the reasons you will see a 403 forbidden error using Nginx is that your directory permissions are not set ok. To fix this:

  • Set 755 permissions from your FTP client to the affected directory.
  • Set 755 permissions from the shell, usign: chmod 755 /path/of/your/directory/ -v

Wrong file permissions: same case as the previous one, try using this fix:

  • Set 644 permissions from your FTP client to the affected file.
  • Set 644 permissions from the shell, usign: chmod 755 /path/of/your/filename.php -v

Directory restrictions by IP:

Check your nginx.conf file, or your sites nginx .conf file in case you have an allow/deny rule that may be blocking your network, for example:

location / {
  # block Tom's computer.
  # allow anyone else in
  # drop rest of the connections
  deny    all;

Lack of index files: when you don’t have any files uploaded named as ‘index’ (it could be index.php, index.html, index.shtml, etc) this is a common reason it will show a 403 error.

Autoindex is off: if you don’t have any index file, but also have autoindex off set at Nginx config, you will have to turn it on using this method:

location /mydirectory {
        autoindex on;
        autoindex_exact_size off;
autoindex on: Turn auto indexing on
autoindex_exact_size off: Show file sizes rounded in kb/mb/gb




Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>