首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的Django网站有网络错误?

为什么我的Django网站有网络错误?
EN

Stack Overflow用户
提问于 2020-08-15 04:43:57
回答 1查看 490关注 0票数 2

我的django网站与默认的SQLite DB集成在一起。昨天,我尝试将它迁移到Postgres,但是由于密码问题,迁移失败了。然后,我试图回到SQLite,只需取消对settings.py中的SQLite部分的注释。但它也失败了。我想我破坏了我的数据库。为了解决这个问题,我使用下面的CLI命令删除SQLite中的所有内容:

代码语言:javascript
复制
python manage.py migrate my-app-name zero

然后,我使用了制造工具,然后迁移了。所以,这里一切看起来都很顺利。然而,现在我面临着与我的网站连接的问题。它不是从网络浏览器启动的。

我不知道我是否破坏了我的整个环境。

我的网站是托管在Ubuntu服务器上的AWS上,它已经启动和运行。最初,我收到了以下错误:

代码语言:javascript
复制
A communication error occurred: The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests

我查看了日志,发现如下所示:

代码语言:javascript
复制
nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument

为了解决这个问题,我遵循了web 链接。但是,这是行不通的。我不知道这是否与我的处境有关。

接下来,我重新启动了我的AWS实例,看看它是否有任何积极的效果。但现在,我明白了

代码语言:javascript
复制
Hmmm… can't reach this page 

在我的浏览器上。

我试着查看nginx服务器日志,它只有以下三行

代码语言:javascript
复制
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

然后,我还检查了syslog,看看它是否有一些重要的信息。我确实通过"tail -f"实时日志注意到了一些事情,我看到了下面的内容:

代码语言:javascript
复制
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>

在查看了上面的内容之后,现在我觉得我的AWS实例发生了一些事情。但我不知道需要做些什么。

注意:在我尝试不成功的DB迁移之前,该网站已经启动并运行。

请帮助,如果需要更多的信息,请告诉我。

谢谢,

curl错误消息:

代码语言:javascript
复制
    "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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-15 06:18:54

基于聊天的讨论。

连接问题是由实例上的ufw 防火墙引起的。防火墙是阻塞到端口80的传入连接中的

临时解决方案是禁用ufw以启用连接并在应用程序上进一步工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63422646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档