DEV Community

William Meier
William Meier

Posted on

Laravel — PHP Artisan Serve Failed

Solve error “Failed to listen on 127.0.0.1:8000 (reason: ?)” when run “php artisan serve”

Resolution
Access your php.ini file in your PHP version folder. If you like me are using Laravel Herd on Windows you can access using the route "%USERPROFILE%.config\herd\bin".
Now in your php.ini change the "variables_order" value.

// before
variables_order = "EGPCS"

// after
variables_order = "GPCS"
Enter fullscreen mode Exit fullscreen mode

Alternative
If this don't work you can also start the server with PHP start command.

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

That's it. I hope it will help you.

Top comments (6)

Collapse
 
xwero profile image
david duymelinck

Please don't use artisan serve. Use a more solid local server setup; like laravel sail.

Collapse
 
williammeier profile image
William Meier

Why is not good use artisan serve in local?

Collapse
 
xwero profile image
david duymelinck

If you are on a windows machine and you move to a linux server you can experience case sensitivity errors. And other OS switching errors.
But there can even be memory problems, because your computer has more than the server.

That is why you best use an environment that is the same or as close as possible to the server.

That is why virtualbox a while ago and docker/podman now are so popular. You can set it up so that you can emulate the problems you are going to experience on the server, on your machine.

Thread Thread
 
williammeier profile image
William Meier

It's a good point, and I haven't thought much about this. I work more on small projects, so I haven't had a problem with this at this point, but in large and scalable projects, your solution will probably be better.
Thanks for the feedback.

Thread Thread
 
xwero profile image
david duymelinck

It is not only big projects that benefit with this way of working.

I was hesitant with all this "ops" on my computer too. But if you catch bugs as soon as possible it will benefit in the long run.

Collapse
 
cesarbrandon profile image
Cesar Brandon

thanks man, how direct 👌