13. LAN Deployment

Chapter 13 of 15 · 15 min

To serve on the local network so other devices can access the chatbot:

# Find your LAN IP
ip addr show | grep "inet "        # Linux
ipconfig getifaddr en0              # macOS

# Start the server on all interfaces
uvicorn app.main:app --host 0.0.0.0 --port 8000

Other devices on the same network access the chatbot at http://<your-lan-ip>:8000.

A failure mode: the firewall on Linux blocks incoming connections by default. Fix with:

sudo firewall-cmd --add-port=8000/tcp --permanent   # firewalld
sudo ufw allow 8000/tcp                              # ufw

On macOS, go to System Preferences > Security & Privacy > Firewall > Firewall Options and allow Python or uvicorn.

For HTTPS (required for some browser features on non-localhost), use a self-signed certificate:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
uvicorn app.main:app --host 0.0.0.0 --port 8000 --ssl-keyfile key.pem --ssl-certfile cert.pem

Browsers will show a certificate warning for self-signed certs. Users must accept the risk.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

From a second device on the same network, navigate to the chatbot and verify streaming works end-to-end.