How To Stop Php Artisan Serve

Killing the Process Manuallyeloping a Laravel application, you may use the built-in PHP development server provided by
the php artisan serve command. This command starts a local server that allows you to test your
application without configuring a full-fledged web server like Apache or Nginx.

However, there may be instances where you need to stop the server. In this blog post, we will discuss how to
stop the PHP Artisan server.

Stopping PHP Artisan Serve

The PHP Artisan server can be stopped using the keyboard shortcut Ctrl + C or
Cmd + C (for macOS users). This will immediately terminate the server process.

To stop the server, simply press the Ctrl + C (or Cmd + C on macOS) keys on your
keyboard while your terminal window is in focus. You should see a message like “Terminated” or “Shutdown
requested”.

Here’s an example of what you might see when stopping the PHP Artisan serve:

    $ php artisan serve
    Laravel development server started: http://127.0.0.1:8000
    ^C
    Shutdown requested...Application server terminated.
    

When using the keyboard shortcut, it’s important to make sure that your terminal window is in focus, and not
another application, to ensure the server is successfully terminated.

Alternative Method: Killing the Process Manually

In some cases, you might need to stop the PHP Artisan server manually. For example, if you accidentally closed
the terminal window where the server was running, you won’t be able to use the keyboard shortcut to stop the
server.

To stop the server manually, you need to find the process ID (PID) of the server and then use the kill command.
Here’s how to do it on different operating systems:

On Linux and macOS

  1. Open a terminal window and use the following command to find the PID of the PHP Artisan server process:

    ps aux | grep "artisan serve"

    This will display a list of processes related to the PHP Artisan server. Look for the process that has
    “artisan serve” in the command and note down its PID.

  2. Use the following command to kill the process, replacing PID with the actual process ID
    you found in step 1:

    kill -9 PID

    The PHP Artisan server should now be stopped.

On Windows

  1. Open a command prompt and use the following command to find the PID of the PHP Artisan server process:

    tasklist /FI "IMAGENAME eq php.exe" /FO TABLE

    This will display a list of processes related to the PHP Artisan server. Look for the process that has
    “php.exe” in the Image Name and note down its PID.

  2. Use the following command to kill the process, replacing PID with the actual process ID
    you found in step 1:

    taskkill /PID PID /F

    The PHP Artisan server should now be stopped.

Conclusion

Stopping the PHP Artisan server is an easy task. You can either use the keyboard shortcut Ctrl + C (or
Cmd + C on macOS) or manually kill the process using its PID. Remember to always stop your server before
closing your terminal window to avoid any issues when starting a new server session.