why am I getting network error for my Django website?

Viewed 459

My django website was integrated with default SQLite DB. Yesterday, I tried migrating it to Postgres, however, due to some password issue, the migration failed. Then I tried to fall back to SQLite just by uncommenting the SQLite portion in settings.py. But it failed too. I guess I broke my Database. To fix the issue I used the below CLI command to delete everything in the SQLite:

python manage.py migrate my-app-name zero

Then I used makemigratons and then migrate. So, here everything seem to go smoothly. However, now I faced the connectivity issue with my website. Its not launching from web browser.

I don't know if I have messed my entire environment itself.

My website is hosted on AWS on Ubuntu server, it has gunicorn and nginx up and running. Initially I was receiving some below error:

A communication error occurred: The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests

I checked the journalctl logs, and I found something like below:

nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument

To try to fix the issue I followed the web link. But, it is not working. I am not sure if this has anything to do with my situation.

Going forward, I restarted my AWS instance, just to see if that has any positive effect. But now, I see

Hmmm… can't reach this page 

on my web browser.

I tried looking into the nginx server logs, and it just has below three lines

2020/08/14 16:27:23 [alert] 3246#3246: *22 open socket #12 left in connection 5
2020/08/14 16:27:23 [alert] 3246#3246: *23 open socket #13 left in connection 6
2020/08/14 16:27:23 [alert] 3246#3246: aborting

Then I also checked syslog to see if it has some important information. I did notice something through "tail -f" real time logs, I see below:

S=0x00 SYN URGP=0
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: 2020-08-15 04:20:43 INFO Backing off health check to every 600 seconds for 1800 seconds.
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: 2020-08-15 04:20:43 ERROR Health ping failed with error - EC2RoleRequestError: no EC2 instance role found
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: caused by: EC2MetadataError: failed to make EC2Metadata request
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: #011status code: 404, request id:
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: caused by: <?xml version="1.0" encoding="iso-8859-1"?>
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: #011"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]:  <head>
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]:   <title>404 - Not Found</title>
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]:  </head>
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]:  <body>
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]:   <h1>404 - Not Found</h1>
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]:  </body>
Aug 15 04:20:43 primarySNS amazon-ssm-agent.amazon-ssm-agent[898]: </html>

After looking at the above, now I feel something happened to my AWS instance. But I am not sure what needs to be done.

Note: The website was up and running before I tried the unsuccessful DB migration.

Please help and let me know if more info is required.

Thank you,

curl error message:

    "curl: (7) Failed to connect to schoolnskill.com port 80: Connection timed out

curl localhost messages:
curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
1 Answers

Based on the chat discussion.

The connection issue was caused by ufw firewall on the instance. The firewall was blocking in the incoming connections to port 80.

The temporary solution was disable ufw to enable connections and further work on the the application.

Related