Ruby on Rails服务器无法启动

时间:2016-09-15 07:49:38

标签: ruby-on-rails server localhost

我一直在尝试使用命令rails server运行我的Rails应用程序 但最近这个错误已经出现了:

  

Macs-MacBook-Pro:jobsboard mac $ rails服务器   =&GT;引导美洲狮   =&GT; Rails 5.0.0.1应用程序从http://localhost:3000开始开发   =&GT;运行rails server -h以获取更多启动选项Puma以单一模式启动...   *版本3.6.0(ruby 2.3.0-p0),代号:Sleepy Sunday Serenity   *最小线程数:5,最大线程数:5   *环境:发展   *听tcp:// localhost:3000退出/Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:266:in   来自initialize': Address already in use - bind(2) for "::1" port 3000 (Errno::EADDRINUSE) from /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:266:in 新'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:266:in   来自add_tcp_listener'的add_tcp_listener' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:260:in 阻止   /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:259:in   来自each' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:259:in add_tcp_listener'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:102:in   每个block in parse' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:85:in 来自   /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/binder.rb:85:in   来自parse' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/runner.rb:133:in load_and_bind'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/single.rb:85:in   run' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/puma/launcher.rb:172:in 从'跑'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/puma-3.6.0/lib/rack/handler/puma.rb:51:in   run' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/rack-2.0.1/lib/rack/server.rb:296:in 从'开始'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/server.rb:79:in   来自服务器的start' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:90:in阻止   /Users/mac/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in tap' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in server'来自   来自/ Users / mac / Documents的/Users/mac/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in run_command!' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in ' /项目/网络   开发/ Ruby On Rails / Jobs Board / jobsboard / bin / rails:9:in   来自require' from /Users/mac/Documents/Projects/Web Development/Ruby On Rails/Jobs Board/jobsboard/bin/rails:9:in'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in   load' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in 来电   /Users/mac/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in   call' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in 从'跑'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/bin/spring:49:in   来自<top (required)>' from /Users/mac/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in 加载'   /Users/mac/.rvm/gems/ruby-2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in   <top (required)>' from /Users/mac/Documents/Projects/Web Development/Ruby On Rails/Jobs Board/jobsboard/bin/spring:13:in 需要'from / Users / mac / Documents / Projects / Web Development / Ruby On   Rails / Jobs Board / jobsboard / bin / spring:13:in <top (required)>' from bin/rails:3:in load'from bin / rails:3:in`'

我可以通过指定一个不同的端口来解决这个问题 - 即使用命令'

  

rails server -p 4000

',但我想用我原来的部署方式。我该如何解决?

P.S。我是Rails的新手,所以请给出简单的说明。 :p赞赏了很多人!谢谢!

增加:

  

上次登录:星期四9月15日13:55:52关于ttys000 Macs-MacBook-Pro:Ruby On   Rails mac $ ps aux | grep rails mac 1040 0.0 0.0   2445080 800 s003 S + 2:02 PM 0:00.00 grep rails mac
  1020 0.0 0.0 2471272 3052 s000 S + 2:02 PM 0:00.01   /Users/mac/.rvm/gems/ruby-2.3.0/gems/rb-fsevent-0.9.7/bin/fsevent_watch   --latency 0.1 /Users/mac/.rvm/gems/ruby-2.3.0/gems/jquery-rails-4.2.1 mac 1019 0.0 0.0 2462056 3032 s000 S + 2:02 PM
  0:00.01   /Users/mac/.rvm/gems/ruby-2.3.0/gems/rb-fsevent-0.9.7/bin/fsevent_watch   --latency 0.1 /Users/mac/.rvm/gems/ruby-2.3.0/gems/coffee-rails-4.2.1 Macs-MacBook-Pro:Ruby On Rails mac $

3 个答案:

答案 0 :(得分:4)

这意味着端口3000不是免费的。您项目的另一个实例已经在使用它。 所以,通过以下命令找到它的过程:

lsof -i :3000

&安培;通过以下方式杀死该过程:

kill -9 processid

您还可以从applcation的临时文件夹中删除进程ID。
或者,您可以通过命令rails s -p 3001

在其他端口上启动应用程序

答案 1 :(得分:1)

打开终端或iTerm并假设您已经在项目目录中。

检查PID过程

lsof -wni tcp:3000

如果它们存在则杀死进程,在终端

上键入
kill -9 PID

答案 2 :(得分:0)

&#34;你是否尝试过再打开它?&#34;

您的应用程序的某个版本可能已在后台运行。看看活动监视器,看看你是否可以看到它,或者如果你对你的终端有信心,你可以试试

ps aux | grep rails

看看它是否出现在那里。然后使用kill xxxx和进程ID结束它,这将为您再次释放端口3000