I was following the tutorial how to setup django in ubuntu 18.04 . I used DigitalOcean first and have some problems with domain ,domain is ending on .app , everything worked fine , web-app works normal on server ip . Let’s imagine my server ip is 192.24.45 ( I don’t want to enter my real server ip) , so bought domain on Go Daddy , changed the name servers to ns1.digitalocean.com. , ns2.digitalocean.com. , ns3.digitalocean.com.
I waited almost 48 hours before configuring the domain on my project
Also I created domain on Digital Ocean Here is screenshots

https://imgur.com/gh3NwDC
https://imgur.com/9JxbF3g
https://imgur.com/BIZEnP5

First screen is DigitalOcean domain page
Second screen is go daddy screen
Third is sites.avaliable file that I needed to create by tutorial

What my problem ?

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.

×
1 answer

Hi @awesomedream21,

There are a couple of things that need to be checked if we don’t have any of the real information. Firstly, I’ll recommend you to make sure your domain is actually loading from your Droplet. To do that, you can simply ping it from your terminal

ping YourDomain.com

Once you are sure it’s loading from the right place would be time to turn your attention to your Droplet. SSH into it and type in the following command

netstat -tulpen

Make sure the output contains both your port 80 (http) and the proxy port Nginx should be redirecting connections to, in most cases and in the tutorial - https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04 is 8000.

If you can’t see it in the output, then something in the configurations file is not properly configured and I’ll recommend going through the Tutorial one more time.

Let’s say you see everything necessary from the above command. In that case, most probably it’s a Firewall issue. You can run a command called nmap on your droplet’s IP to see which ports are publicly open. To do so, open a new terminal window and run

nmap YourDropletIP

If you can’t see either port 80 or 8000 than your application is not reachable by the world. You’ll need to enable both ports for the public in your Firewall.

If after all that nothing is working still, then I’ll recommend turning your attention to your Nginx error_log.

Regards,
KDSys

by Justin Ellingwood
Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server...
  • Hi @KDSys , thanks for replying ! I thought and put all logs files here , i didn’t fix this , here is my error log file :

    error log

    
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to 0.0.0.0:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to [::]:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to 0.0.0.0:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to [::]:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to 0.0.0.0:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to [::]:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to 0.0.0.0:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to [::]:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to 0.0.0.0:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: bind() to [::]:80 failed (98: Address already in use)
    2020/05/14 20:25:53 [emerg] 9173#9173: still could not bind()
    2020/05/14 20:27:06 [alert] 7637#7637: unlink() "/run/nginx.pid" failed (2: No such file or directory)
    
    
    

    nginx.service

    
    root@ubuntu-s-1vcpu-1gb-ams3-01:~# systemctl status nginx.service
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2020-05-14 21:21:10 UTC; 23min ago
         Docs: man:nginx(8)
      Process: 1872 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS
      Process: 1886 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
      Process: 1875 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
     Main PID: 1890 (nginx)
        Tasks: 2 (limit: 1151)
       CGroup: /system.slice/nginx.service
               ├─1890 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
               └─1893 nginx: worker process
    
    May 14 21:21:10 ubuntu-s-1vcpu-1gb-ams3-01 systemd[1]: Stopped A high performance web server and a reverse proxy server.
    May 14 21:21:10 ubuntu-s-1vcpu-1gb-ams3-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
    May 14 21:21:10 ubuntu-s-1vcpu-1gb-ams3-01 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
    May 14 21:21:10 ubuntu-s-1vcpu-1gb-ams3-01 systemd[1]: Started A high performance web server and a reverse proxy server.
    
    
    

    netstat -tulpen

    
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name
    tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      0          20189      933/sshd: root@pts/
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      0          28704      1890/nginx: master
    tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      101        15441      700/systemd-resolve
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          18276      893/sshd
    tcp6       0      0 ::1:6010                :::*                    LISTEN      0          20188      933/sshd: root@pts/
    tcp6       0      0 :::80                   :::*                    LISTEN      0          28705      1890/nginx: master
    tcp6       0      0 :::22                   :::*                    LISTEN      0          18287      893/sshd
    udp        0      0 127.0.0.53:53           0.0.0.0:*                           101        15440      700/systemd-resolve
    
    

    Is there something you need else ?

    Best regards !!! thanks of answering again

    • Hi @awesomedream21,

      Looking at the logs and from netstat, I see a couple of things, firstly for some reason Nginx was giving errors about port 80 being taken however I can see at the moment it’s working properly. Most probably something else was listening to that port.

      Lastly, what I see from netstat, It seems like your gunicorn instance is not running thus making it impossible for you to reach your website. I’ll assume something has been missed in the configuration.

      I’ll recommend going over the tutorial I posted in my first reply, even if it means starting all over again from the beginning.

      Regards,
      KDSys

Submit an Answer