In this post will give you example of Laravel php artisan serve not working. I would like to share with you php artisan serve not working in Laravel.
The php artisan serve command is a best method to start a development server for Laravel application. Some time user fetch the issue php artisan serve command not working. This post provides simple solution about that issue.
Normally, php artisan command works perfectly. Even port is busy and run with another port.
When Laravel php artisan serve not working occurs?
- Another process is already using the default port (8000)
- Either PHP is installed, or the PATH environment variable is not set correctly.
Solutions to fix php artisan serve issues
1. Check if the port is already in use
- Run the following command to check processes using port 8000
netstat -ano | findstr :8000
- Ensure the PATH environment variable is set correctly. Then run following command.
cd your_project_folder
composer install
php artisan cache:clear
php artisan config:clear
php artisan optimize
2. Run Laravel app using php command
php -S localhost:8000 -t public/
Now, you are able to access with following URL:
http://localhost:8000
3. Run Laravel app with different port
Here, we will simply run below command to run laravel app with different port.
cd your_project_folder
php -S localhost:9000 -t public/
http://localhost:9000
Read also: How to create interface in Laravel 11?
The php artisan serve command is tool, but issue can arise due to various like port conflicts, missing PHP or dependency problems.
I hope this tutorial help you.