简体   繁体   English

Rails Server不断退出(SocketError)

[英]Rails Server Keeps Exiting (SocketError)

Rails noob here. Rails noob在这里。 I'm trying to work through Michael Hartl's Ruby on Rails Tutorial, but every time I run rails server, it keeps Exiting and shows me a SocketError. 我正在尝试通过Michael Hartl的Ruby on Rails教程,但是每次运行Rails服务器时,它都会一直退出并向我显示SocketError。 I was able to run the server just fine this past weekend using wifi from a startup, so I'm guessing it has something to do with my internet connection/firewall? 在过去的一个周末,我可以使用初创公司的wifi运行服务器,所以我猜它与我的Internet连接/防火墙有关吗? I also ran into the same problem with the server at the library this afternoon. 今天下午,我在图书馆的服务器上也遇到了同样的问题。

Any help is appreciated! 任何帮助表示赞赏! Thanks in advance. 提前致谢。

=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-02-23 22:33:11] INFO  WEBrick 1.3.1
[2015-02-23 22:33:11] INFO  ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
Exiting
/Users/awo/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/socket.rb:232:in  `getaddrinfo': getaddrinfo: nodename nor servname provided, or not known (SocketError)

我最近遇到了相同的问题,我通过将127.0.0.1 localhost记录添加到private/etc/hosts文件来解决了

I had messed with my hosts file in the past, and removing and creating a new default one (with localhost included) seemed to do the trick . 过去,我搞砸了我的hosts文件,删除并创建一个新的默认文件(包括localhost)似乎可以解决问题。 Got mine from here : 这里得到我的:

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

I'm thinking the path was screwed up or there were some ninja whitespaces lurking in my /private/etc/hosts file. 我以为这条路搞砸了,或者我的/ private / etc / hosts文件中有一些忍者空格。

First you need to identify the port id of rails server so run below command that give list of PID which run on 3000 port 首先,您需要确定rails服务器的端口ID,因此请在下面的命令中运行,该命令会给出在3000端口上运行的PID的列表

lsof -wni tcp:3000

the number in the PID column to kill the process: PID列中的数字可以终止进程:

kill -9 PID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM