DEV Community

Jervi
Jervi Subscriber

Posted on

Laravel `php artisan serve` Fails on Windows (Ports 8000–8010) - Here is a quick fix

Laravel on Windows Be Like: “No Port for You” 😤

source from Jervi-writes blog

You install Laravel.
You run:

php artisan serve
Enter fullscreen mode Exit fullscreen mode

Laravel replies:

Failed to listen on 127.0.0.1:8000
Failed to listen on 127.0.0.1:8001
...
Failed to listen on 127.0.0.1:8010
Enter fullscreen mode Exit fullscreen mode

Every. Single. Port. ❌
Firewall? Fine.
Project? Fresh.

If you’re on Windows (Herd / XAMPP / custom PHP), welcome to the club.


The Real Culprit 🕵️‍♂️

It’s just PHP config, especially for Windows

Some Windows PHP builds ship with this:

variables_order = "EGPCS"
Enter fullscreen mode Exit fullscreen mode

The Fix (30 seconds, no reinstalling)

1️⃣ Find your active php.ini

php --ini
Enter fullscreen mode Exit fullscreen mode

Example:

C:\Users\{username}\.config\herd\bin\php84\php.ini
Enter fullscreen mode Exit fullscreen mode

2️⃣ Edit ONE line

Change this:

variables_order = "EGPCS"
Enter fullscreen mode Exit fullscreen mode

To this:

variables_order = "GPCS"
Enter fullscreen mode Exit fullscreen mode

3️⃣ Restart terminal & run again

php artisan serve
Enter fullscreen mode Exit fullscreen mode

Boom 💥

Starting Laravel development server: http://127.0.0.1:8000
Enter fullscreen mode Exit fullscreen mode

Why This Works (TL;DR)

Laravel trusts $_SERVER more than $_ENV.
Windows PHP said “nah”.
You fixed the order.
Peace restored 🧘‍♂️


Can’t edit php.ini?

Temporary hacks:

php -S localhost:8000 -t public
Enter fullscreen mode Exit fullscreen mode

or

php artisan serve --host=localhost --port=8080
Enter fullscreen mode Exit fullscreen mode

But let’s be real — fixing variables_order is the grown-up solution.

Top comments (0)