排除 MacOS 上的 localhost/apache - 连接被拒绝错误

发布于 2025-01-09 14:46:30 字数 1455 浏览 1 评论 0原文

我正在尝试调试 localhost 连接拒绝错误。对于上下文,我有一个 Flask 应用程序,我试图在本地运行。我使用 gunicorn 启动应用程序,并注意到它正在端口 8000 上运行。

Starting gunicorn 20.1.0
[2022-02-24 05:38:49 -0800] [21269] [INFO] Listening at: http://127.0.0.1:8000 (21269)
[2022-02-24 05:38:49 -0800] [21269] [INFO] Using worker: sync
[2022-02-24 05:38:49 -0800] [21271] [INFO] Booting worker with pid: 21271

我尝试了几件事,包括:

  1. 重新启动 apache 服务器 - sudo apachectl restart
  2. 刷新 dns: sudo Killall -HUP mDNSResponder;sudo Killall mDNSResponderHelper;sudo dscacheutil -flushcache
  3. 运行httpd
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using MacBook-Air-2020.local. Set the 'ServerName' directive globally to suppress this message
    (48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
    (48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
  1. telnet 127.0.0.1
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    telnet: Unable to connect to remote host
  1. 当我在浏览器中输入 http://127.0.0.1/ 时,我得到

It Works!

我还能尝试什么?我正在使用 gunicorn 服务器在本地部署/运行应用程序。

I am trying to debug localhost connection refused error. For context, I have a Flask App that I am trying to run locally. I launch the app using gunicorn and notice that it is running on port 8000.

Starting gunicorn 20.1.0
[2022-02-24 05:38:49 -0800] [21269] [INFO] Listening at: http://127.0.0.1:8000 (21269)
[2022-02-24 05:38:49 -0800] [21269] [INFO] Using worker: sync
[2022-02-24 05:38:49 -0800] [21271] [INFO] Booting worker with pid: 21271

I have tried several things including:

  1. restart apache server - sudo apachectl restart
  2. flush dns: sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
  3. Run httpd
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using MacBook-Air-2020.local. Set the 'ServerName' directive globally to suppress this message
    (48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
    (48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
  1. telnet 127.0.0.1
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    telnet: Unable to connect to remote host
  1. When I enter http://127.0.0.1/ in browser, I get

It works!

What else can I try? I am using gunicorn server to deploy / run the App locally.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘逸的'云 2025-01-16 14:46:30

这对我来说很有效:

sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache

This did the trick for me:

sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文