Score:0

domain "refused to connect" running django app on digitalocean droplet

in flag

I want to deploy a site on a digitalocean droplet. So far, it works as expected when I hit the IP address 123.45.678.910, but when I go to my domain name, I see "This site can't be reached, my-site.com refused to connect" on Chrome. I am able to ping mysite.com and I see that it goes to the right IP address.

I connected my Namecheap domain to my droplet using this tutorial. I've waited 24 hours which I think should be enough time for the domain name to propogate.

I don't see anything recent in the nginx error logs. When I check the status of nginx, gunicorn, and gunicorn.service on the droplet they all appear to be running.

Here's my /etc/nginx/sites-avaliable/my-site :

    listen 80;
    listen [::]:80;
    server_name my-site.com 123.45.678.910;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /root/my-site/;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}


I tried to install an SSL cert with this command:

sudo certbot --nginx -d my-site.com -d www.my-site.com

I don't think it worked, but I'm not sure if this could have something to do with it.

Let me know if there is any more information that you think I should include, I've never done this before so any information is helpful.

Thanks!

EDIT: I'm seeing this in the output of systemctl status nginx. It's just a warning (famous last words) but I'm wondering if it could be the causes as using the IP address works but the domain name doesn't.

     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-03-22 00:40:42 UTC; 3min 1s ago
       Docs: man:nginx(8)
    Process: 185516 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 185527 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 185528 (nginx)
      Tasks: 2 (limit: 1131)
     Memory: 3.2M
     CGroup: /system.slice/nginx.service
             ├─185528 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             └─185529 nginx: worker process

Mar 22 00:40:42 my-site systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 22 00:40:42 my-site nginx[185516]: nginx: [warn] conflicting server name "my-site.com" on 0.0.0.0:80, ignored
Mar 22 00:40:42 my-site nginx[185516]: nginx: [warn] conflicting server name "my-site.com" on [::]:80, ignored
Mar 22 00:40:42 my-site nginx[185527]: nginx: [warn] conflicting server name "my-site.com" on 0.0.0.0:80, ignored
Mar 22 00:40:42 my-site nginx[185527]: nginx: [warn] conflicting server name "my-site.com" on [::]:80, ignored
Mar 22 00:40:42 my-site systemd[1]: Started A high performance web server and a reverse proxy server.


in flag
Silly question, but is the configuration file also in `/etc/nginx/sites-enabled`? This is usually done with a symbolic link (using `ln -s`) for consistency. After making a symbolic link, nginx will need to be restarted in order to flush the cache and reload the enabled sites.
ellen avatar
in flag
@matigo I created the symlink but had made some changes to my `sites-available` file afterwards, so I just recreated it. I still get the same issue unfortunately!
in flag
After making changes, nginx must be restarted (or reloaded). The configuration files are only read when the web engine starts up
ellen avatar
in flag
@matigo I have done `systemctl restart nginx` and also tried `nginx -t` (tests are successful). The issue persists
ellen avatar
in flag
I found something that might be helpful coming out of `systemctl status nginx`, I will update above
ellen avatar
in flag
@matigo updated
Score:0
in flag

This WAS related to the firewall.

First of all, I was getting weird errors when I initially tried running the certbot command and had to reinstall pip. I followed the below commands:

sudo apt-get update
sudo apt-get install python-certbot-nginx
sudo ufw allow ssh
sudo ufw enable
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo ufw status

The status command shows that everything is allowed (for now). Now I add my SSL cert:

sudo certbot --nginx -d my-site.com -d www.my-site.com

It will prompt you on whether you want all sites directed to secure access.

After updating my firewall and adding my SSL cert, my-site.com is now live! :D

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.