我有一个 python 服务器在树莓派的 8000 端口上运行,并想让它在本地网络中访问,但目前无法正常工作。
接口 wlan0 配置了 IP 10.0.0.69 和网络掩码 255.255.255.0。
我无法访问本地网络中的服务器(从不同的主机):
root@DESKTOP-Lukas:~# curl http://10.0.0.69:8000
curl: (7) Failed to connect to 10.0.0.69 port 8000: Connection refused
Run Code Online (Sandbox Code Playgroud)
我也无法从树莓派访问服务器:
lukas@raspberrypi:~ $ curl http://10.0.0.69:8000
curl: (7) Failed to connect to 10.0.0.69 port 8000: Connection refused
Run Code Online (Sandbox Code Playgroud)
服务器正在运行并侦听端口 8000:
lukas@raspberrypi:~ $ sudo netstat -tnlp | ack 8000
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 743/python
Run Code Online (Sandbox Code Playgroud)
服务器在使用 localhost 时正确响应:
lukas@raspberrypi:~ $ curl localhost:8000
<h1>Not Found</h1><p>The requested URL / was not found on this server.</p>
Run Code Online (Sandbox Code Playgroud)
防火墙允许端口 8000 …