Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

RoboRobok's avatar

Why does Laravel Sail use both 0.0.0.0 and 127.0.0.1?

I'm no expert when it comes to ports, but I found it surprising that Laravel Sail starts 0.0.0.0 session, but 127.0.0.1 is working as well. What's the deal? Why couldn't it be just good old 127.0.0.1 (localhost)?

0 likes
1 reply
rodrigo.pedra's avatar

0.0.0.0 means the built-in PHP server running inside sail's docker instance will serve requests for any IP bound to the server.

The docker instance usually is available to your network on a different IP, so in your docker file the port 80 from your local machine is bound to the port 80 of the docker machine.

Therefore when you type 127.0.0.1:

  • your browser sends a request to the local port 80 on your machine
  • your machine's port 80 is bound to the docker instance's port 80, but in a different local IP
  • due to the bounding the request is passed to the docker instance
  • as the PHP web server is running to accept requests for any IP's bound to this server it accepts and handle the request.

Image this, on a server with multiple network interfaces, it will have multiple IP addresses bound to it. You can configure a webserver to respond only to one of these IPs and have different web applications served from the same server. By binding the webserver to the 0.0.0.0 address you are telling the webserver to respond requests from any of the bound requests.

Please or to participate in this conversation.