You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10+Python3.6.4下Flask服务运行但浏览器不显示Hello World求助

Troubleshooting Flask Hello World Not Loading in Browser (Windows 10, Python 3.6.4)

Hey there, let's work through this Flask issue you're facing. You've already tried a bunch of common fixes—changing ports, using your IPv4, reinstalling Python/Flask, disabling firewalls, resetting proxies, and even testing with (then removing) a CORS plugin. Let's dive into some additional steps that might get your Hello World page showing up.

Key Troubleshooting Steps

1. Validate Your Flask Code First

Sometimes a tiny typo can break everything. Make sure your minimal app matches this exact structure (it's easy to miss something like the if __name__ == '__main__': block):

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)

The host='0.0.0.0' ensures the app listens on all your machine's network interfaces, and debug=True will spit out detailed errors in your terminal if something's failing silently.

2. Check the Flask Console for Hidden Errors

When you launch your app, don't just minimize the terminal—watch it closely. If there's an error (like a missing dependency, port access denied, or syntax issue), it'll show up here. For example, OSError: [WinError 10013] means even after changing ports, your system is blocking Flask from using that port.

3. Test with the Loopback Address (127.0.0.1)

Instead of your public IPv4, try accessing http://127.0.0.1:5000 directly. This bypasses any network router or firewall rules that might be blocking external access to your machine. Even if you tried your IPv4 before, the loopback is a critical test to confirm the server is running locally.

4. Inspect Browser Dev Tools for Network Clues

Open your browser's developer tools (hit F12 or Ctrl+Shift+I), go to the Network tab, then reload the page. Look at the request status:

  • Connection refused: Flask isn't actually listening on the port you're trying to access.
  • Timeout: Something (firewall, network config) is blocking the connection.
  • 404 Not Found: Your route is misconfigured (double-check the @app.route('/') line).

5. Verify Flask is Listening on the Port

Open Command Prompt and run this command (replace 5000 with your port):

netstat -ano | findstr :5000
  • If no results show up: Flask failed to bind to the port. Double-check your code and terminal errors.
  • If you see a PID: Open Task Manager, go to the Details tab, and find that PID. If it's not your Python process, another app is using the port—kill it or pick a new port.

6. Rule Out Browser-Specific Issues

Try loading the page in a different browser, or use incognito/private mode. Even after uninstalling the CORS plugin, leftover browser extensions or cached data might be interfering. Incognito mode disables most extensions and uses a fresh cache, so it's a quick way to isolate the problem.

7. Confirm You're Using the Correct Python Version

Multiple Python installations can cause confusion. Run this in the terminal where you start Flask:

python --version

Make sure it shows Python 3.6.4. If not, use py -3.6 to explicitly launch Python 3.6, then install Flask again for that version if needed.

8. Reset Winsock (Advanced)

If all else fails, corrupted Winsock settings can break network connectivity for apps like Flask. Open Command Prompt as Administrator and run:

netsh winsock reset

Restart your computer, then try running the Flask app again.


内容的提问来源于stack exchange,提问作者Akshaya Natarajan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:22:29