nginx default shows on my custom domain name, but my DO IP shows the proper site

March 10, 2018 13.5k views
Nginx Django Ubuntu 16.04

Hi everyone,

I’m a bit confused as to where exactly my problem lies. I have a custom domain name, which I have connected to the DO nameservers. I’m reasonably sure this is set up correctly since as the title states, when I go to that website, I get the “welcome to nginx” default page.

However, when I go to my DO droplet’s IP;, I can see my webapp correctly.

I suspect the problem lies with my nginx sites-available/philheijkoopsite file (that’s what I’ve called it), containing the following:

server {
    listen 80;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/phil/mysite;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/phil/mysite/philheijkoopsite.sock;

Is the server_name not specific enough? I have checked and the .sock file has been created, gunicorn is running correctly. I’ve tried restarting nginx, none of that has changed my currently problem, anyone have any ideas?

update I have added a new rule to my sites-available/philheijkoopsite file:

server {
    listen 80;

    return 302 $scheme://;

Which now redirects my incoming traffic to my IP, and thus they at least get to the web app. However, this does the opposite of what I want. If I reverse the current set up in my file, ie have the url redirect to my IP, it will do that, but the IP still serves a 400 Bad Request error.

4 Answers

Hi there,

As long as you see the Welcome to Nginx page, your domain is pointing to the correct server. Now, we need to make it point to the correct page.

The first thing I noticed is the server_name directive. Do you have special reason why is it set to the Droplet’s IP address?
Try to replace IP with your domain name such as:


Restart Nginx by running the systemctl restart nginx and then give it a try. Maybe, you’ll have to clear browser cache, or to use the incognito mode.

The rule you added later isn’t needed, it should work out-of-box.
For more info how to set up this, I recommend you to look at the How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04 tutorial.
If nothing helps, you can take a look at the How To Troubleshoot Common Site Issues on a Linux Server tutorial.

by Justin Ellingwood
Everybody runs into issues with their website at one point or another. This guide will help you troubleshoot some common issues and get your site running again.

I’ve tried that; when it shows


I get a Bad Request (400) error when I go to that URL, and my droplet’s IP then shows the nginx default welcome page.

So the reason it’s set to my droplet’s IP is that’s something I tried that worked.

  • I recommend you to take a look at logs for more details. You shouldn’t see Error 400 - Bad Request.

    Logs should be located in the /var/log/nginx directory. You should have two files — access.log and error.log. Take a look at the error.log file to see can you find the root of the problem.

    • I have checked the logs:

      error.log is empty since I rotated it a while ago. So the 400 error isn’t coming from nginx (or not from an nginx error).

      access.log shows me this: - - [10/Mar/2018:21:38:03 +0000] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36" - - [10/Mar/2018:21:38:20 +0000] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36" - - [10/Mar/2018:21:38:23 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36" - - [10/Mar/2018:21:41:03 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36" - - [10/Mar/2018:21:41:05 +0000] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36"

      The 400 errors come from me trying to access the URL, the 304 errors are connected to me going to my IP directly, which gives the default welcome page. What’s interesting is that they’re all coming from the “-” referer.

      • Without error logs, I can’t for sure help you to find the problem. But maybe we can try to guess what could be the problem.

        I think this directive in the Nginx configuration file can be problematic: proxy_pass http://unix:/home/phil/mysite/philheijkoopsite.sock;.
        Try without that http, i.e. proxy_pass unix:/home/phil/mysite/philheijkoopsite.sock;, maybe that will do the job.

        Make sure to restart nginx after you change it to put changes in the effect: sudo systemctl restart nginx. You can also test the configuration file for errors by running the nginx -t command.

        • Your suggested edit throws an error when I nginx -t.

          • Oh, my bad, it is indeed http://unix:/home/phil/mysite/philheijkoopsite.sock;, I overlooked something.

            Maybe it could be permissions issue? Have you tried moving the directory outside your home, e.g. somewhere to /var/www or any other? You can give permissions to web server by doing something along chown -R www-data:www-data mysite.

        • I’m unable to reply to your latest comment, so I’ll continue here. I have tried something along those lines. I was originally putting all my files in /var/opt/site, but that didn’t help.

          I don’t think it’s a permission thing since I’ve chown 777 -R my whole directory earlier in a different snapshot of this, no difference. Especially since the files served fine with my original file set up, just at the wrong location.

          ** update ** Sniffing around the logs, when I checked the status of my nginx, I got
          mrt 10 21:56:55 ubuntu-s-1vcpu-1gb-nyc1-01-philheijkoopsite systemd[1]: nginx.service: Failed to read PID from file /run/ Invalid argument
          in between two attempts to start the web server. It worked after and is set at active, so I didn’t look too closely at first.

Did you resolve the problem? I have the same one.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!