Home / Snippets / How to set Port Number for php artisan serve Command in Laravel
How to set Port Number for php artisan serve Command in Laravel cover

How to set Port Number for php artisan serve Command in Laravel

4.2K

3 years ago

0 comments

To set the "php artisan serve" command port number to anything other than 8080 you can specify the port number using the "--port" flag and then specify the port number.

Specify Port From Command Line


You can write your code like below.
php artisan serve --port=9000
For the host, if you are not using localhost or 127.0.0.1 you can pass in the "--host" flag as well.
php artisan serve --host=127.0.0.2

Specify Port From Configuration File


The 2nd method is to specify the port from the configuration file or right away export it from the terminal and you can write it like the following.
Specify the file definition inside the .env environment file.
# .env file
SERVER_PORT="9000"
Or terminal export definition.
export SERVER_PORT="9000"
Then after you have done that you can right away call the artisan serve command like you normally would.
php artisan serve
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this