Laravel on Windows Be Like: “No Port for You” 😤
source from Jervi-writes blog
You install Laravel.
You run:
php artisan serve
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
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"
The Fix (30 seconds, no reinstalling)
1️⃣ Find your active php.ini
php --ini
Example:
C:\Users\{username}\.config\herd\bin\php84\php.ini
2️⃣ Edit ONE line
Change this:
variables_order = "EGPCS"
To this:
variables_order = "GPCS"
3️⃣ Restart terminal & run again
php artisan serve
Boom 💥
Starting Laravel development server: http://127.0.0.1:8000
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
or
php artisan serve --host=localhost --port=8080
But let’s be real — fixing variables_order is the grown-up solution.
Top comments (0)