Home > Enterprise >  Running Laravel on local machine
Running Laravel on local machine

Time:06-10

I am trying to run a laravel project in my local machine. It starts normally on http://127.0.0.1:8000 but when I try to open the url in the browser the port changes to 8001 and the new url is http://127.0.0.1:8001. When I try to open this in the browser, again the port changes to 8002.

Image showing the issue

composer.json

My PHP version is 7.4.1. If anyone else faced this issue earlier or knows how to fix this issue, please help in fixing this issue.

Thank you.


Update 1: Noticed something. Whenever database related code is executed, this issue is popping up. For example, when I try to execute the following code shown in the image, it runs smoothly and I can see the output in the browser. Case when the code runs smoothly

But when I change the code to the following, the issue shows up. Case when the issue shows up. This is not any database heavy query but why this issue? Any leads would be very helpful.


Update 2: Found nothing in laravel logs but found the following in the apache error log which is given below:

[Thu Jun 09 21:37:24.988703 2022] [mpm_winnt:crit] [pid 2660:tid 704] AH02538: Child: Parent process exited abruptly. Child process is ending

[Thu Jun 09 21:37:27.399609 2022] [core:warn] [pid 8084:tid 576] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?

[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00455: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.4.1 configured -- resuming normal operations

[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00456: Apache Lounge VC15 Server built: Aug 11 2019 12:20:04

[Thu Jun 09 21:37:27.446479 2022] [core:notice] [pid 8084:tid 576] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'

[Thu Jun 09 21:37:27.446479 2022] [mpm_winnt:notice] [pid 8084:tid 576] AH00418: Parent: Created child process 10064

[Thu Jun 09 21:37:28.196453 2022] [mpm_winnt:notice] [pid 10064:tid 664] AH00354: Child: Starting 150 worker threads.

CodePudding user response:

Try this parameter I think help you

php artisan serve --port=8080

CodePudding user response:

This highly, might be a problem to the code, you've write-ed, not a Laravel problem. I've faced issues like this before for a long time ago, so you might check :

  • The code is processing in blade or controller.
  • Or it might be a memory issues related to PC (might not be, related to this issue, but i had a lots of memory issues back then when i had low-end PC and all these issues was happening.)

As I said, my first guess is the code, so you might need to share the code find out, what is happening.

Also conflicts in reserved ports will be avoided anyway, for example if you set your local environment server to something else(8080), same issue will happen again.

And sometime if you close your terminal without closing local environment, new php artisan serve will run the local environment anyway, for example, my terminal/IDE was closed but application was serving, and doing php artisan serve not forced me to close and run a new local environment like yours, it was trying to serve again, but old one was doing conflicts.

So as I said again, it might be a code issue.

Double check your code or share it to find the issue.

  • Related