why my domain is not working in nginx, django?

March 6, 2019 1.1k views
Django Ubuntu 18.04


  1. i purchesd new domain like vtuallinoneresources.com in nextraone hosting services .
  2. then i replaced the servername space to ns1,2,3 digital ocean
  3. i checked the "https://www.inmotionhosting.com/support/tools/visual-domain-routing?domain=vtuallinoneresources.com" where my new domain server point to old or new NS

  4. its pointing to new digital ocean NS

5.in my :$ nano /etc/nginx/sites-available/hello i changed ip address to domain name
```server {
listen 80;

# add here the ip address of your server
# or a domain pointing to that ip (like example.com or www.example.com)

#servername my ip address;
name vtuallinoneresources.com;

keepalive_timeout 5;
client_max_body_size 4G;

6. in django settings.py file added domain name in allowed host like this ALLOWED_HOSTS = ['','localhost','','vtuallinoneresources.com']

7. but is not working now with domain name instead of ip address 

1 comment
3 Answers

trail and error i solved

Hey there! I am not exactly sure how you have configured nginx blocks but the first thing I have noticed is your Domain is not resolving to any IP. This is because you have added the domain on DigitalOcean account but haven't added any A record and CNAME for the domain.

Please add an A record for vtuallinoneresources.com to and a CNAME record for www.vtuallinoneresources.com Is AN alias of vtuallinoneresources.com

Keep me posted on how it goes after the DNS correction.

  • hi i did correction can you check now my account properly configured????/

    • DNS looks good now.

      www.vtuallinoneresources.com. 43200 IN CNAME vtuallinoneresources.com.
      vtuallinoneresources.com. 3600 IN A
      ;; Received 87 bytes from in 85 ms

      However the website loads Default nginx page.

      Please crosscheck the virtual host file on your Droplet and make sure it is properly proxied to django socket and the socket is running on expected port.

      Keep us posted if you need any further guidance on this and if there are additional questions or concerns please don't hesitate to reply with them.

      • hi please look at

        1. http://vtuallinoneresources.com ==> (this one redirected to domain purchased website default page )
        2. * *==>( this one redirected to default nginx page)

        i am full confused where wrong please take a look my nginx file
        what i checked files

        1. hemanth@ubuntu-vtu:/etc/nginx/sites-available$ ls


        2. hemanth@ubuntu-vtu:/etc/nginx/sites-enabled$ ls

          below is nginx file **

        ```upstream simpleacademyserver {
        server unix:/home/hemanth/django-server/run/gunicorn.sock fail_timeout=0;

        Redirect all non-encrypted to encrypted

        server {
        server_name vtuallinoneresources.com;
        listen 80;
        rewrite ^/(.*) https://vtuallinoneresources.com/$1 permanent;

        server {
        servername vtuallinoneresources.com;
        listen 443;
        ssl on;
        certificate /home/hemanth/vtuallinoneresourcescom/vtuallinoneresourcescom.crt;
        sslcertificatekey /home/hemanth/ssl/vtuallinoneresources.com.key;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
        # add here the ip address of your server
        # or a domain pointing to that ip (like example.com or www.example.com)
        #server_name vtuallinoneresources.com;
        keepalive_timeout 5;
        client_max_body_size 4G;
        #access_log /home/hemanth/django-serevr/logs/nginx-access.log;
        error_log /home/hemanth/django-server/logs/nginx-error.log;
        #access_log /home/hemanth/django-serevr/logs/nginx-as.log;
        location /static/ {
            alias https://hemanth-boos-d-static.s3.amazonaws.com/static/;
        location /media/ {
            alias   https://hemanth-boss-d-static.s3.amazonaws.com/media/;
        # checks for static file, if not found proxy to app
        location / {
            try_files $uri @proxy_to_app;
        location @proxy_to_app {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          #proxy_pass http://app_server;
          if (!-f $request_filename) {
                proxy_pass http://simple_academy_server;


Have another answer? Share your knowledge.