LoginSignup
6
4

More than 3 years have passed since last update.

Address already in use でPHPのビルトインサーバーが立ち上がらない時の対処方法

Last updated at Posted at 2019-11-26

phpのビルトインサーバーを立ち上げようとした際に、

php -S 192.168.33.10:8000

のコマンドを実行すると、

Failed to listen on 192.168.33.10:8000 (reason: Address already in use)

等とエラーが出てしまう時の対処方法のメモ。

解決手順

1.使用しているPID番号(プロセスID)を確認

ps ax | grep php

ターミナルで上記のように入力すると、現在しているポートが表示される。

[vagrant@localhost My_php]$ ps ax | grep php
 9375 pts/0    S+     0:00 php -S 192.168.33.10:8000 -t public_html/

※一番左の数字が「PID番号」なので、上記の例だと「9375」

2.既に解放しているプロセスを終了する

kill PID番号

3.再度、php -S 192.168.33.10:8000 を実行

php -S 192.168.33.10:8000
PHP 7.1.33 Development Server started at Mon Nov 25 03:37:42 2019
Listening on http://192.168.33.10:8000
Document root is /home/vagrant/My_php
Press Ctrl-C to quit.

これでビルトインサーバーが立ち上がるはずです。

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4