skip to Main Content

I recently installed Laravel Herd for my Laravel projects. However, I encountered some issues:

Nginx log error:

2024/06/05 22:20:17 [emerg] 8764#8936: bind() to 127.0.0.1:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)

When running the php artisan serve command, I get the following output:

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: ?)

Everything was working fine when I was using XAMPP and Composer, which I had installed manually.

However, after installing Laravel Herd for my Laravel projects, I encountered these issues. I have checked the ports.

PS C:WindowsSystem32> for ($port = 8000; $port -le 8010; $port++) {
>>     $connections = Get-NetTCPConnection -LocalPort $port -ErrorAction SilentlyContinue
>>     if ($connections) {
>>         Write-Output "Port $port is in use."
>>     } else {
>>         Write-Output "Port $port is free."
>>     }
>> }
>>
Port 8000 is free.
Port 8001 is free.
Port 8002 is free.
Port 8003 is free.
Port 8004 is free.
Port 8005 is free.
Port 8006 is free.
Port 8007 is free.
Port 8008 is free.
Port 8009 is free.
Port 8010 is free.

disabled and enable the firewall, check if my php.ini file is present(which it is) and I have also restarted my laptop

2

Answers


  1. The error message Failed to listen on 127.0.0.1:8000 (reason: ?) indicates that the PHP built-in server is unable to bind to the specified address and port. This can happen for several reasons, including:

    Port 8000 is already in use: Another process might be using port 8000.
    Permission issues: There might be permission issues preventing the server from binding to the port.
    Network issues: There might be network configuration issues or restrictions.

    Login or Signup to reply.
  2. Change the default laravel serve port number if you can, like

    php artisan serve --port=8008
    

    or you can kill you can kill the process manually by running this command :

    kill $(lsof -t -i:8000)
    
    or 
    
    fuser -n tcp -k 8000 (for linux based user)
    

    Then run serve command :

    php artisan serve
    

    This will work sure.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search