如何在同一WiFi网络下从树莓派Zero W访问树莓派3的网页
Hey David, let's troubleshoot this step by step—since both devices are on the same SAMBA WiFi network, getting this working should be manageable once we rule out common roadblocks. Here's what to check and try:
1. Verify Basic Network Connectivity First
Before diving into web server issues, confirm the two Pis can talk to each other:
- On your Pi Zero W, open a terminal and run:
ping 192.168.43.39 - If you see successful replies (like
64 bytes from 192.168.43.39: icmp_seq=1 ttl=64 time=2.3ms), your network connection is solid. If not:- Double-check both devices are connected to the SAMBA WiFi network (not different networks with the same name).
- Confirm the Pi 3's IP is still
192.168.43.39(runhostname -Ion the Pi 3 to verify).
2. Ensure the Pi 3's Web Server is Listening for External Connections
Web servers sometimes default to only listening on the local loopback (127.0.0.1), which blocks access from other devices. To check:
- On the Pi 3, run this command to see which ports your web server is using (replace
80with your custom port if you changed it):netstat -tulpn | grep :80 - Look for a line that includes
0.0.0.0:80or192.168.43.39:80—this means the server is accepting connections from all interfaces. If you only see127.0.0.1:80:- For Apache: Edit the
000-default.conffile (usually in/etc/apache2/sites-available/) and changeListen 127.0.0.1:80toListen 80, then restart Apache withsudo systemctl restart apache2. - For Nginx: Edit your server block config and set
listen 80;instead oflisten 127.0.0.1:80;, then restart Nginx withsudo systemctl restart nginx.
- For Apache: Edit the
3. Directly Access the Pi 3's Web Pages
Once connectivity and server settings are confirmed, access the pages from your Pi Zero W:
- Open a web browser (like Midori or Chromium) and navigate to:
- Pi 3's index page:
http://192.168.43.39 - Pi 3's camera page:
http://192.168.43.39/camera.html
- Pi 3's index page:
- If you don't want to use the IP, you can also use the Pi 3's hostname (default is
raspberrypi)—tryhttp://raspberrypi.localorhttp://raspberrypi(some networks support hostname resolution without.local).
4. Check for Firewall Blocks
Raspberry Pi OS doesn't enable a firewall by default, but if you installed ufw or another firewall tool on the Pi 3, it might be blocking port 80:
- On the Pi 3, allow HTTP traffic with:
sudo ufw allow 80/tcp - Or temporarily disable the firewall to test:
sudo ufw disable
5. Test with a Command-Line Tool (Bypass Browser Issues)
If the browser isn't working, use curl on the Pi Zero W to rule out browser-specific problems:
curl http://192.168.43.39/camera.html
If you see the HTML content of the page printed in the terminal, the server is working—your browser might have cache issues or need a settings tweak.
内容的提问来源于stack exchange,提问作者David Mathias

