Django + Nginx configuration: why getting “Welcome to nginx!"?

Posted January 17, 2019 1.6k views

I have Django + Nginx + Gunicorn on Ubuntu. Certificates generated with Letsencrypt.

In /etc/nginx/sites-available/myproject I have:

server {
    listen 80;
    return 301$request_uri;

server {

    listen 443;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;

    client_max_body_size 1G;

    root /home/myname/myproject;

    location / {
        include proxy_params;
        proxy_pass https://unix:/home/myname/myproject/myproject.sock;

In /etc/nginx/sites-available/default, except commented lines, I have:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
            try_files $uri $uri/ =404;

In /etc/nginx/sites-enabled I have default and myproject.

When I go to, I see “Welcome to nginx!”. What am I doing wrong that it redirects to “Welcome to nginx!”?

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

I wish someone would answer this I have the same problem!