我一直在关注Hartl的RoR教程并正在开发toy_app,但是当我尝试打开服务器继续进行2.2.1"用户游览"时,我收到此错误信息。任何帮助将不胜感激。
:~/workspace/toy_app (master) $ rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 4.2.0.rc2 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-12-09 16:29:49] INFO WEBrick 1.3.1
[2014-12-09 16:29:49] INFO ruby 2.1.4 (2014-10-27) [x86_64-linux]
Exiting
/usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/socket.rb:206:in `bind': Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE)
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/socket.rb:206:in `listen'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/socket.rb:461:in `block in tcp_server_sockets'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/socket.rb:232:in `each'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/socket.rb:232:in `foreach'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/socket.rb:459:in `tcp_server_sockets'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/utils.rb:75:in `create_listeners'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:132:in `listen'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:113:in `initialize'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/httpserver.rb:45:in `initialize'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/rack-1.6.0.beta2/lib/rack/handler/webrick.rb:32:in `new'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/rack-1.6.0.beta2/lib/rack/handler/webrick.rb:32:in `run'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/rack-1.6.0.beta2/lib/rack/server.rb:286:in `start'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/railties-4.2.0.rc2/lib/rails/commands/server.rb:80:in `start'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/railties-4.2.0.rc2/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/railties-4.2.0.rc2/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/railties-4.2.0.rc2/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/railties-4.2.0.rc2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/railties-4.2.0.rc2/lib/rails/commands.rb:17:in `<top (required)>'
from /home/ubuntu/workspace/toy_app/bin/rails:8:in `require'
from /home/ubuntu/workspace/toy_app/bin/rails:8:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/ubuntu/workspace/toy_app/bin/spring:16:in `require'
from /home/ubuntu/workspace/toy_app/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
答案 0 :(得分:2)
一个问题很好的问题通常已经包含答案:
/usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/socket.rb:206:in `bind':
Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE)
某些内容似乎已在本地计算机的端口8080上运行。您不能同时拥有两个相同的地址和端口。您需要终止它或者选择其他端口。
答案 1 :(得分:0)
您无法在同一端口上运行两台服务器。只需尝试使用端口8080上的不同端口或终止服务器。
命令:
rails server
在端口3000上启动服务器
要使用不同的端口,您需要使用选项-p
指定端口。
在您的情况下,您使用了端口8080,因为您的$PORT = 8080