Port Address already in use
In this guide, we’ll show you step-by-step how to stop or free port 8000 on Mac or Linux systems. If you’ve ever tried running your Laravel development server:
php artisan serveand got this message:
Failed to listen on 127.0.0.1:8000 (reason: Address already in use)
INFO Server running on [http://127.0.0.1:8001].It means port 8000 is already in use — most likely by another Laravel instance or a process that didn’t close properly. This is one of the most common issues developers face when using php artisan serve.
For MacOS & Linux Users
Step 1: Check Which Process Is Using Port 8000
lsof -i :8000Explanation:
lsof— lists open files and network connections.-i :8000— filters processes using port 8000.
You should see output similar to this: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME php 5432 neon 3u IPv4 0x… 0t0 TCP 127.0.0.1:8000 (LISTEN)
Take note of the PID (Process ID).
In this example, the PID is 5432.
Step 2: Kill the Process Using the PID
Once you’ve identified the PID, stop the process with the following command:
kill -9 5432Replace 5432 with the actual PID from your terminal output.
⚠️ The
-9flag forces the process to stop immediately.
Now try running your Laravel server again:
php artisan serveIt should now run correctly on:
http://127.0.0.1:8000
For Windows Users
If you’re on Windows, the commands are a little different.
Step 1: Find the Process ID
netstat -ano | findstr :8000Step 2: Kill the Process
taskkill /PID <PID> /FReplace <PID> with the process ID you found.
Happy Codding!!!
