Application is not calling by NGINX

Posted May 4, 2021 43 views
NginxCentOSPythonDjangoPython FrameworksDeployment

As I was followed your tutorial on how to configure NGINX + Django. However, at last I was not able to see my application om browser. I am still getting message “Welcome to nginx!” on my browser. Currently I am using Centos7.5. Kindly let me know that how to trace the errors or steps to overcome this issue.

Thanks in advance. Regards, Venu

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

It is possible that you have multiple Nginx server block files in /etc/nginx/conf.d and the incorrect one is being served.

You can check that with the following command:

sudo ls -l /etc/nginx/conf.d

If this is the case I would recommend removing the one that is not needed.

If there is only one file in there, then it could be a problem with the configuration. Feel free to share the content of the file here so that I could try to advise you further.


  • Hi Bobby, Many thanks for your swift reply. This is first time I am working on deploying Django using NGINX.

    As you said I have checked “sudo ls -l /etc/nginx/conf.d” and the reponse is “total 4 -rw-r–r– 1 root root 1077 May 4 13:59 default.conf”

    In folder “/etc/nginx/conf.d” there is only one file default.conf

    I have included below lines in defualt.conf

    #server {
     #   listen       80;
      #  server_name  localhost;
        #access_log  /var/log/nginx/host.access.log  main;
       # location / {
        #    root   /usr/share/nginx/html;
         #   index  index.html index.htm;
    server {
        listen 80;
        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/Dev_User_1/InvestmentProject/InsuranceTrackerV44;
        location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://unix:/home/Dev_User_1/InvestmentProject/InsuranceTrackerV44/InsuranceTracker.sock;
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        # proxy the PHP scripts to Apache listening on
        #location ~ \.php$ {
        #    proxy_pass;
        # pass the PHP scripts to FastCGI server listening on
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #location ~ /\.ht {
        #    deny  all;

    However, InsuranceTracker.sock is not there in my file structure.


    edited by MattIPv4
    • Hi there,

      This looks quite OK, what I could suggest is to run an Nginx configuration test with the following command:

      sudo nginx -t

      If you get any errors feel free to share them here, if not you could try restarting Nginx:

      sudo systemctl restart nginx

      Let me know how it goes.

      • Hi Bobby,

        Here is the error after executed the command sudo nginx -t

        nginx: [emerg] “location” directive is not allowed here in /etc/nginx/conf.d/default.conf:37
        nginx: configuration file /etc/nginx/nginx.conf test failed