Hosting Local Web App
Overview
To allow Machine B to access a web application running on Machine A within the same WiFi network, you'll need to start the web app on Machine A and ensure its server is bound to the correct network interface. Here’s a step-by-step guide:
Steps
1. Start the Web App on Machine A
- Bind to All Interfaces: When starting your web server on Machine A, make sure it listens on
0.0.0.0
or the specific local IP (192.168.1.15
), not justlocalhost
or127.0.0.1
.- Example (Node.js/Express):
node app.js
# In app.js: app.listen(3000, '0.0.0.0'); - Example (Python/Flask):
flask run --host=0.0.0.0 --port=5000
- Other frameworks: Consult documentation for how to specify host/interface.
- Example (Node.js/Express):
2. Check Firewall/Antivirus
- Ensure that any firewall or antivirus software on Machine A is not blocking incoming connections to the port your app is using (e.g., 3000, 5000, 80).
- On Windows, add an inbound rule to allow the port in Windows Defender Firewall.
- On macOS/Linux, use
ufw
,firewalld
, or equivalent to open the port.
3. Access from Machine B
- On Machine B, open a web browser and navigate to:
Replace
http://192.168.1.15:PORT/
PORT
with the port number your web app is running on.
4. Troubleshooting
- Cannot Connect? Check port, IP address, network profile, and firewall settings.
- Check App Status: Use
netstat -tuln
(Linux/macOS) ornetstat -ano
(Windows CMD) to confirm the app is listening on the network interface.
Example
- If your Flask app is running on port 5000 on Machine A, access it from Machine B at:
http://192.168.1.15:5000/
Summary
- Start your web app, binding to all interfaces.
- Allow network access through firewall/antivirus on Machine A.
- Access via Machine A’s IP and the correct port from Machine B.
This setup works for most web servers and frameworks.