How to Fix Nginx 403 Forbidden Error? – eduCBA

Introduction to Nginx Forbidden We face

the Nginx Forbidden


many times in our application; we face this error while using the nginx server. Also, most of the time, this is not related to the nginx server. The forbidden Nginx error contains error code 403, which means we don’t have permission to access the specified Web Parts. So this error will cause many reasons in our application; Investigating the cause of the error is very important.

<img src

=”” alt=”Nginx Forbidden” />

What is Nginx Forbidden


To debug and fix the banned 403 nginx error, we need to check the correct error logs and take appropriate action. The nginx forbidden 403 error is the nginx server’s way of telling the user that we are requesting a resource, but we can’t give it to us. Nginx forbidden 403 is technically not a bug, but it contains the status code of http. The response code in 403 headers is intentionally returned in several cases, as if the user is blocked from requesting the page, resource, or entire site of the application.

How to fix banned Nginx 403 error?

When it comes to web resources and servers, we encounter errors that cause when performing configurations and maintenance. At the moment of encountering this error, we need to fix the same as soon as possible.

The forbidden Nginx 403 error is nothing more than that it will generate the status code and display it on the user’s screen when a client tries to access part of the web server with insufficient permissions.

The following figure shows the error message that will occur on the user’s screen when this error occurs.

error message

Below is the cause of the nginx 403 forbidden error and how we can fix the same user-specified action. To improve nginx forbidden 403 issue, first, we need to install nginx server on our system.

Next we are installing nginx server on ubuntu system. We are installing nginx server using apt-get command as follows.


: apt-get install nginx


nginx server installation using apt-get

command After installing

nginx server, we check the installed version of nginx using the following command. We can check the nginx version and the running status of the nginx server.


: nginx -V


nginx installed version

The common cause of this error is an incorrect configuration file in the index section. The nginx will specify which index file we need to load and the order in which we are loading; Determines that the index file is not in the directory. So we need to define the following index file and upload it; We need to define the index files in the location policy as follows.


location / { index index.html index.htm index.html inde.php; }


define the following index file and upload it

The index page was located in the directory from which the automatic index parameter was disabled. Therefore, we can use the automatic index parameter of the index as follows.


location / { autoindex on; autoindex_exact_size off; }


After changing the settings, we need to restart the nginx server to take the effect of the changed port. Before restarting the nginx server, we run the nginx -t command to check if the nginx configuration file contains any errors or not.


: nginx -t service nginx restart


restart nginx server Nginx

403 HTTP forbidden

http contains the different causes of these errors. First, we check the process ID of our nginx server to check the status of the server that is running or not; we can use the following command to find the process ID.


ps -ef | grep -i nginx


contains a different cause of these errors

nginx 403 forbidden error also occurs due to directory restrictions by using IP. We have to check it; We need to check the configuration file in case we have to allow or deny the network blocking rule. We must comment that line in the configuration file if we deny any IP. Or we can leave all network traffic from our website allowing all rules as follows. We need to define this rule in the location policy of the nginx configuration file.


location / { # deny; # allow; allow all; }


network traffic of our website allowing all rules

The forbidden Http 403 error will occur for multiple reasons, but all errors are the same, such as we do not have access to the data directory or file we are accessing. So when we encounter a forbidden nginx error, we should try to debug the error using the suggested suggestions.

Incorrect settings Nginx Forbidden

The banned nginx 403 will also result in incorrect settings of folder and file permission. Nginx will successfully serve customer-specific resources and files; Nginx will contain the read, write, and execute permissions on the entire path. To resolve this error, we need to change the data directory permission to 755 and the file permission to 644. Also, we need to make sure that the user who was running owns the nginx files.


: chown -R www-data:www-data * chmod 755 /var/lib/nginx/



Nginx Forbidden 9

This error can occur on

both the server side and the client side. To solve the client-side problem, we need to

perform the following client-side operations as follows:

First of all, we need to make sure that

  • we are accessing the correct location on the
  • web. We

  • need to clear the browser cache when this kind of problem occurs
  • .

  • We must make sure that a proxy or firewall will allow us to access web resources.

If we assume that we are not sure how to fix the nginx forbidden issue, then we can investigate the same using the error log



The nginx

forbidden 403 error is the nginx server’s way of telling the user that we are requesting a resource, but we can’t give it to us. The forbidden Nginx error contains error code 403, which means we don’t have permission to access the specified Web Parts.

Recommended Articles

This is a guide to Nginx Forbidden. Here we discuss the introduction and how to fix the banned nginx 403 error with incorrect settings. You can also take a look at the following articles for more information:


    location policy Add_header

  1. Nginx Nginx WAF
  2. Nginx
  3. FastCGI