问题
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)
回答1:
I had the same problem recently, which I resolved by adding 127.0.0.1 localhost
record to the private/etc/hosts
file
回答2:
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.
回答3:
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
来源:https://stackoverflow.com/questions/28689733/rails-server-keeps-exiting-socketerror