72
57

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 5 years have passed since last update.

rails sしようとしたらAddress already in useと言われた

Last updated at Posted at 2017-09-23

起きた問題

いつも通りrails sでローカルサーバーを立ち上げようとしたら

$ rails s
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2017-03-16 15:48:31] INFO  WEBrick 1.3.1
[2017-03-16 15:48:31] INFO  ruby 2.3.1 (2016-04-26) [x86_64-darwin16]
Exiting
/Users/kenichi/.rbenv/versions/2.3.1/lib/ruby/2.3.0/socket.rb:205:in `bind': Address already in use - bind(2) for 127.0.0.1:3000 (Errno::EADDRINUSE)
	from /Users/kenichi/.rbenv/versions/2.3.1/lib/ruby/2.3.0/socket.rb:205:in `listen'
	from /Users/kenichi/.rbenv/versions/2.3.1/lib/ruby/2.3.0/socket.rb:759:in `block in 
.
.
.

どうやら3000番ポートが既に使われているみたいですね。

Address already in use - bind(2) for 127.0.0.1:3000 (Errno::EADDRINUSE)

解決法

まずプロセスの状態を確認

$ ps ax | grep rails
kenichi          12661   0.0  0.0  4267752    880 s003  S+   11:11PM   0:00.00 grep ... rails
kenichi          69441   0.0  0.0  4295984   1784 s001  S+   11:11PM   0:00.32 /bin/sh ...

やっぱり使われてました。

killコマンドを使ってプロセスを止めてあげましょう。
−9の後に、プロセスの番号(今回は12661)を指定してあげるとプロセスを停止させることができます

$ kill -9 12661

これでいつも通りrails sできるようになりました。

72
57
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
72
57

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?