why my domain is not working in nginx, django?

Posted March 6, 2019 14.7k views
DjangoUbuntu 18.04


  1. i purchesd new domain like in nextraone hosting services .
  2. then i replaced the servername space to ns1,2,3 digital ocean
  3. i checked the “” where my new domain server point to old or new NS

  4. its pointing to new digital ocean NS 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 or

#servername my ip address;

keepalive_timeout 5;
client_max_body_size 4G;

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

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

1 comment

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
3 answers

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 to and a CNAME record for Is AN alias of

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. 43200 IN CNAME 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. ==> (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 {
        listen 80;
        rewrite ^/(.*)$1 permanent;

        server {
        listen 443;
        ssl on;
        certificate /home/hemanth/vtuallinoneresourcescom/vtuallinoneresourcescom.crt;
        sslcertificatekey /home/hemanth/ssl/;

        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 or
        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/ {
        location /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;