Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

princeparaste's avatar

Not able to run local site and api at the same time laravel

I am not able to run local site and api at the same time laravel i am running the local site in port: 8000

http://localhost:8000

and i am also using same port for api but its not working.

In env file this my urls

APP_URL=http://localhost:8000
API_URL=http://localhost:8000/
0 likes
2 replies
fideloper's avatar

Hi!

You can’t run two things (such as web servers) servers on the same port. So you’ll need to use something like port 8000 for one and port 8001 for the other.

princeparaste's avatar

I did try using different port but its giving me error:

Failed to connect to localhost port 8001:

here are my env file urls =>

APP_URL=http://localhost:8000
API_URL=http://localhost:8001/

I run 2 commands

php artisan serve
php artisan serve --port=8081

Please or to participate in this conversation.