Set port for php artisan.php serve

Solution 1:

Laravel 5.8 to 8.0 and above

Simply pass it as a paramter:

php artisan serve --port=8080

You may also bind to a specific host by:

php artisan serve --host=0.0.0.0 --port=8080 

Or (for Laravel 6+) you can provide defaults by setting SERVER_PORT and SERVER_HOST in your .env file. You might need to do php artisan cache: clear as well. (thanks @mohd-samgan-khan)

And if you want to run it on port 80, you probably need to sudo.

Solution 2:

as this example you can change ip and port this works with me

php artisan serve --host=0.0.0.0 --port=8000