简体   繁体   中英

Rails Server Keeps Exiting (SocketError)

Rails noob here. 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. 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? 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 . 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.

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

lsof -wni tcp:3000

the number in the PID column to kill the process:

kill -9 PID

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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