This error didn't occurred until now. Whenever I run php artisan serve, It gives me 127.0.0.1:8000, it works a couple of minutes but after that the page just keeps loading until I restart the server and gives me an error Failed to listen on 127.0.0.1:8000 (reason: Address already in use) and gives me other port. Is there a way to trace what uses the default port?
you could use the netstat command to grep whether the port is in used and used by what service/process. Usually 8000 and above is not for system use hence most likely you have custom services listening on the port and not close it properly.
Anyhow, you may just ignore it and use other port number above 8000 instead
Remember that the php built in server can only run one request at a time and cannot listen for a new request until it has finished the last one. If you have any scheduler tasks, or are calling third party api then new web requests will be blocked until this has finished.
ps aux | grep -i artisan shows that you have other artisan serve running. Kill the process 15750 to see if it is the origin of your problems. Have you tried to run the PHP built-in server?
Okay, apparently dompdf is the culprit. I noticed that when I visit a page that goes to print view, the error occurred but it stopped after I modified my code. Thanks for helping everyone!