Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php artisan serve can't bind to any port #34229

Closed
vitorsemeano opened this issue Sep 9, 2020 · 18 comments
Closed

php artisan serve can't bind to any port #34229

vitorsemeano opened this issue Sep 9, 2020 · 18 comments

Comments

@vitorsemeano
Copy link

vitorsemeano commented Sep 9, 2020

  • Laravel Version: 8.0.1
  • PHP Version: 7.4.10
  • OS: Windows 10
  • Database Driver & Version: no database needed

Description:

After upgrading to laravel 8, and running the command php artisan serve, it responds with an error recursively, like so:

image

This behavior does not happen if i change php version to 7.4.5 or switch to laravel 7.x.

Steps To Reproduce:

  1. have a laravel project started up with version 8.x
  2. make sure you have the most recent stable php version installed (at time of writing 7.4.10)
  3. run php artisan serve
  4. see that the command can't bind itself to any port

As additional note, i debugged the generated command (running php artisan serve), and copy paste it directly in the command line and it worked, without returning any error.

If you need any more info, just ask.

Thanks

@driesvints
Copy link
Member

We don't use windows ourselves so feel free to send in a PR which fixes this on Windows.

@AegirLeet
Copy link
Contributor

Can't reproduce this. Might be something on your machine interfering.

@vitorsemeano
Copy link
Author

Hi, thanks for your feedback.

I managed to resolve this issue. Not quite sure what as the cause, but it was related with something not right in php.ini.

So what i did was use the standard php.ini-development (that comes with a pre built php), and add whats missing in the file and should work. In any doubt try only renaming php.ini-development to php.ini without modifying its contents.

@mikecobb-io
Copy link

The one line I needed to change in my php.ini to fix this problem was
variables_order = "EGPCS"
to
variables_order = "GPCS"

@vitorsemeano
Copy link
Author

Something to do with the Env variable. No ideia how this affects the core functionality of php built in server to this degree.

@agustavo87
Copy link

agustavo87 commented Oct 19, 2020

Something to do with the Env variable. No ideia how this affects the core functionality of php built in server to this degree.

It's in the 8^ laravel upgrade. Because the server if one run it directly works fine:

php -S 127.0.0.1:8000  -t public/ server.php

and in Laravel 7 artisan serve works without problems (windows 10, php 7.4.6).

@Devang142
Copy link

Devang142 commented Sep 11, 2021

For me, it was silly mistake. I have installed php in new machine but php.ini was missing. So, I have created php.ini file from php.ini-production file and then php artisan serve command worked fine as expected.

@isharainduranga
Copy link

php.ini was missing .Check whether your composer has installed.

@amirazad1
Copy link

After upgrading php7 to php8 for XAMPP,I receive this error.re-creating php.ini from php.ini-production works for me.

@ttc0419
Copy link

ttc0419 commented Feb 5, 2022

Hi guys, I created a merge request #40819 to fix the issue. Could you try it out to see if it's working?

@omniaSayed
Copy link

The one line I needed to change in my php.ini to fix this problem was variables_order = "EGPCS" to variables_order = "GPCS"

i have been with this problem for days and your solution worked thank

@Afer13
Copy link

Afer13 commented Jan 25, 2023

injimjin ihkhh uhihkiuhhhu

@niu-grandpa
Copy link

The one line I needed to change in my php.ini to fix this problem was variables_order = "EGPCS" to variables_order = "GPCS"

Thanks!This is a very good

@dhurbamis
Copy link

Yes, it was php.ini

change below
variables_order = "EGPCS"
to
variables_order = "GPCS"

@MiN6JI
Copy link

MiN6JI commented Jul 29, 2024

variables_order = "EGPCS"

to

variables_order = "GPCS" 

If you are using laravel herd and facing same issue and can't find the php.ini just right click the herd icon from the taskbar and open the configuration files you will see all your php version folders, click onto the one of the folder as per your configuration of php and search for php.ini and make the above changes.

@kamasuPaul
Copy link

In case anyone using PVM on windows comes here looking: I installed a new version of PHP using PVM, but it didn't come with a php.ini file. That was causing the issue. To fix it, I just had to add a php.ini file.

@scrucher
Copy link

scrucher commented Nov 7, 2024

if you're using windows open your powershell and type
php --ini
that comand will provide the path to your php.ini file, then go to your laravel app click on vendor => laravel => sail => runtime then choose which php version instaed on your machine copy the php.ini file and post it to the initial php.ini file that will be able to solve the issue on windows OS
image
image
image

@imantarmizi
Copy link

For windows PowerShell,

PS D:\xampp\htdocs\testing-project-1> php artisan serve
Failed to listen on 127.0.0.1:8000 (reason: ?)
Failed to listen on 127.0.0.1:8001 (reason: ?)
Failed to listen on 127.0.0.1:8002 (reason: ?)
Failed to listen on 127.0.0.1:8003 (reason: ?)
Failed to listen on 127.0.0.1:8004 (reason: ?)
Failed to listen on 127.0.0.1:8005 (reason: ?)
Failed to listen on 127.0.0.1:8006 (reason: ?)
Failed to listen on 127.0.0.1:8007 (reason: ?)
Failed to listen on 127.0.0.1:8008 (reason: ?)
Failed to listen on 127.0.0.1:8009 (reason: ?)
Failed to listen on 127.0.0.1:8010 (reason: ?)
PS D:\xampp\htdocs\testing-project-1> php --ini
Configuration File (php.ini) Path:
Loaded Configuration File: C:\Users\User.config\herd\bin\php83\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)

Step 1: Copy this = C:\Users\User.config\herd\bin\php83\php.ini
Step 2: Go to File Explorer on your local hardware
Step 3: Paste the copied path
Step 4: Search "variables_order"
Step 5: Change "EGPCS" to "GPCS"
Step 6: php artisan serve

This worked for me in 2024 with php version 8.3.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests