How to Run Laravel Project On Differrent Port

Published on Apr 10, 2022

Hello Artisans, today I'll show you how you can run your Laravel application with different port or how you can access your application from different computer. Sometimes we may need to access via another computer/mobile to see responsiveness or performance on our mobile/computer. So, let's see how we can run our application on different port/devices.

Laravel Serve Command

We basically use the below serve command to serve our application

php artisan serve

Which will serve our application in the following URL.

 http://127.0.0.1:8000

Now it might be possible that this port is already used by another application. Then we need to serve our Laravel application on different port. So, we can use the below command to serve it another port.

php artisan serve --port=8080

Which will serve our application in the following URL.

 http://127.0.0.1:8080

Now sometimes we run into a problem where we need to serve our application on different devices. Like sometimes we need to run our application on mobile devices so that we can check our application performance and responsive view on mobile devices. So, how we can do it? For that you need to complete the below steps

  1. Open your cmd and type ipconfig
  2. Note down your ipv4 address. Like mine was 192.168.0.118
  3. Then run the following command in your terminal
php artisan serve --host=192.168.0.118

Which will serve our application in the following URL.

http://192.168.0.118:8000

Which can be accessed through any devices under the same network.

That's it for today. Hope you'll enjoy this tutorial. Thanks for reading. 🙂

Comments (0)