12
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Rails】終了できない!A server is already runningの対処!

Last updated at Posted at 2019-07-29

##はじめに
railsをいじっていると、pumaを起動させたままターミナルを閉じたりすると
pumaが終了出来なくなることがあるのでメモを残します。

エラー文

A server is already running. Check /app/tmp/pids/server.pid.

##症状

ec2-user:~/environment/develop (master) $ rails s
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
A server is already running. Check /home/ec2-user/environment/develop/tmp/pids/server.pid.
Exiting

control+Cで終了できなくなりました。

##解決方法
上記のコードに書いてある/home/ec2-user/environment/develop/tmp/pids/server.pidを開くと
ポート番号が書いてあったので、kill -9で強制終了させます。

kill -9 番号

これで、rails sで再起動すればOKです

#追記
これを打ち込んだ方が、簡単に削除出来ます!

$ rm -f tmp/pids/server.pid

docker使ってる方は、Makefileとかに下記を定義しておくと楽です。

run:
docker-compose exec web /bin/bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b 0.0.0.0"

これでmake runて打てば、Railsの起動が楽になります。

12
7
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
12
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?