Error "Failed to listen on (reason: Address already in use)" resolved when run localhost in Laravel

Laravel is the most popular and open-source MVC type PHP framework to create web application. In a recent time, Laravel even crossed Wordpress in creating new websites.
Laravel application server runs on 8000 port when run php artisan serve command in Terminal in localhost. But sometimes when run this command, if port 8000 is already runs by other service, then it failed to run Laravel application with the error "Failed to listen on (reason: Address already in use)" or Laravel application starts on the port 8001.

There are some ways you can solve this issue. First one is run your Laravel server on other port with the bellow command.

php artisan serve --port 9000

Second way is to kill service which runs on the port 8000 and then run your Laravel application on port 8000. For that first run bellow command, it will display servies which runs on the port.

sudo netstat -plnt

And then find which service runs on the port 8000 and kill that Program name with command. For example, in this here, 23769/php7.2 service is running on the port.

killall -9 php7.2

Or kill service by its PID with command:

sudo kill 23769

Now you can serve your localhost using php artisan serve command again. Thank you reading this article. Please feel free to give your feedback in the bellow comment section.