The default private_network configuration in Vagrant creates a NAT-based network that isn't accessible from other machines on your LAN. While port forwarding (forwarded_port) allows access from the host machine, it doesn't solve the local network sharing requirement.
To make your Vagrant VM accessible on the local WiFi network, you'll need to configure bridged networking:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/precise64"
config.vm.network "public_network", ip: "192.168.1.101", bridge: "en0: Wi-Fi (AirPort)"
config.vm.network "forwarded_port", guest: 80, host: 8080
end
- Replace "192.168.1.101" with an available IP in your router's DHCP range
- The bridge parameter should match your host's WiFi interface name (en0 for macOS, wlan0 for Linux)
- Ensure the IP is outside your router's DHCP range to avoid conflicts
After provisioning, verify connectivity:
# On host machine
ping 192.168.1.101
# From another device on the same WiFi
curl http://192.168.1.101
If bridged networking isn't feasible, you can combine host port forwarding with router port forwarding:
# Vagrantfile
config.vm.network "forwarded_port", guest: 80, host: 8080
# Then configure your router to forward:
# External Port 80 → Host IP:8080
If accessibility problems persist:
- Check VM firewall rules:
sudo ufw allow 80/tcp
- Verify web server binds to 0.0.0.0 not 127.0.0.1
- Ensure proper network interface assignment in VM
When exposing your development environment:
- Change default credentials for any services
- Consider implementing basic auth for web access
- Use SSH tunneling for sensitive applications
When working with Vagrant, the default networking configuration creates a private network that's only accessible from the host machine. Your current configuration:
config.vm.network :private_network, ip: "192.168.56.101"
config.vm.network :forwarded_port, guest: 80, host: 8080
This setup allows access to the VM's web server only through localhost:8080
on your host machine, but not from other devices on your WiFi network.
To make your Vagrant VM accessible on your local WiFi network, you need to configure a bridged network adapter. This allows the VM to obtain an IP address from your router's DHCP server, just like any other device on your network.
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: "192.168.1.100"
Replace en0: Wi-Fi (AirPort)
with your actual network interface name (use ifconfig
on Mac/Linux or ipconfig
on Windows to find it). The IP address should be in your router's subnet range.
For a development environment, you might want to use DHCP:
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", use_dhcp: true
However, for a web server, a static IP is often preferable to maintain consistent access.
If bridging isn't working, you can try advanced port forwarding:
config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "0.0.0.0"
This makes the forwarded port available on all network interfaces of your host machine.
Ensure your host machine's firewall isn't blocking incoming connections:
# On Linux
sudo ufw allow 80/tcp
# On macOS
sudo pfctl -e
After making changes, verify the setup:
# Inside the VM
ifconfig
curl localhost
# On another machine on your WiFi
ping [VM_IP]
curl http://[VM_IP]
- Check VirtualBox network settings (if using VirtualBox provider)
- Verify your router's DHCP range
- Test with simple services first (like a basic Python HTTP server)
- Check
vagrant up
output for network-related errors