
Ubuntu VM에서 간단한 플라스크 서버를 실행하려고 합니다.
를 사용하여 ssh로 연결할 수 있지만 [email protected]
실행하면 curl 123.456.789:8000
서버가 수신 대기 중임에도 불구하고 작업 시간 초과가 발생합니다.
* Serving Flask app "app.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
내 iptables -vnL
출력은 다음과 같습니다
Chain INPUT (policy ACCEPT 11434 packets, 8571K bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8000
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 7590 packets, 4856K bytes)
pkts bytes target prot opt in out source destination
따라서 포트 8000을 사용하는 것이 좋습니다. On lsof
에서도 볼 수 있습니다.
flask 16268 robin 3u IPv4 167958 0t0 TCP 127.0.0.1:8000 (LISTEN)
전에는 실제로 그런 일을 해본 적이 없어서 어리석은 실수일 수도 있지만, 여기서 잘못되었을 수 있는 다른 것이 있다고 생각할 수 있습니까?
답변1
Python/Flask 앱은 127.0.0.1을 수신하므로 localhost에 대한 액세스가 제한됩니다.
필요한 것에 따라 특정 IP 또는 0.0.0.0에서 수신 대기하도록 만드세요.