SocketError (getaddrinfo: Name or service not known) - Sunspot/Solr Rails development

前端 未结 7 920
轮回少年
轮回少年 2020-12-15 07:15

I have had lots of trouble with deploying my rails 3.0.10 application to Ubuntu 10.04 server with Passenger, Capistrano, nginx and MySQL (and even more trouble with apache2)

相关标签:
7条回答
  • 2020-12-15 07:53

    For me it was sufficient to remove the search line in my resolv.conf. My company inserted automatically it's own domain and my hostname was not a FQDN in my hosts file. This is a test environment obviously.

    0 讨论(0)
  • 2020-12-15 07:55

    I've been having the same issue with rails and logstasher on OSX, couldn't figure out what was going on until I read this post. Thought I'd add this so that anyone else having the same kind of issue with logstasher can find something...

    `=> Booting Unicorn
    => Rails 4.2.5 application starting in development on http://0.0.0.0:3000
    => Run rails server -h for more startup options
    => Ctrl-C to shutdown server
    Exiting
    /Users/xx/Projects/xx/config/environments/development.rb:80:in 'getaddress': getaddrinfo: nodename nor servname provided, or not known (SocketError)`
    

    Fix was to add my machine hostname to the list under /etc/hosts for 127.0.0.1

    0 讨论(0)
  • 2020-12-15 07:56

    It could be that one of your third party service URLs is incorrect. For example, we had the wrong SMTP mail address. An exception within the app caused it to email the error to the admins and it failed with the error. Here's how you know when it's a bad address:

    irb(main):009:0> Socket.gethostbyname("example.net")
    SocketError: getaddrinfo: Name or service not known
    
    0 讨论(0)
  • 2020-12-15 08:00

    I added this line to the top of file app/controllers/search_controller.rb

    require 'resolv-replace'
    

    Or alternatively you can put it to initializers/requires.rb

    0 讨论(0)
  • 2020-12-15 08:02

    just a wild guess, any chance you are using localhost as the hostname? Try changing localhost to 127.0.0.1

    0 讨论(0)
  • 2020-12-15 08:08

    I had a similar issue, which I worked around by editing the /etc/resolv.conf

    before

    nameserver 10.0.x.x
    search example.com
    

    after

    #nameserver 10.0.x.x
    nameserver 8.8.8.8
    #search example.com
    
    0 讨论(0)
提交回复
热议问题