getaddrinfo: nodename nor servname provided, or not known

前端 未结 13 1581
梦谈多话
梦谈多话 2020-12-02 12:14

I have a Ruby on Rails application that I am deploying on a computer running Mac OS X 10.6. The code where the problem arises is run by a delayed_job. The problem only occur

相关标签:
13条回答
  • 2020-12-02 12:36

    In my config/application.yml I have changed this

    redis:
        url: "redis://redis:6379/0"
    

    to this

    redis:
        url: "redis://localhost:6379/0"
    

    and it works for me

    0 讨论(0)
  • 2020-12-02 12:37

    I restarted my computer (Mac Mountain Lion) and the problem fixed itself. Something having to do with the shell thinking it was disconnected from the internet I think.

    Restarting your shell in some definite way may solve this problem as well. Simply opening up a new session/window however did not work.

    0 讨论(0)
  • 2020-12-02 12:40

    I ran into a similar situation today - deploying an app to a mac os x server, and receiving the 'getaddrinfo' message when I tried to access an external api. It turns out that the error occurs when the ssh session that originally launched the app is no longer active. That's why everything works perfectly if you ssh into your server and run commands manually (or launch the server manually) - as long as you keep your ssh session alive, this error won't occur.

    Whether this is a bug or a quirk in OS X, I'm not sure. Here's the page that led me to the solution - http://lists.apple.com/archives/unix-porting/2010/Jul/msg00001.html

    All I had to do was update my capistrano task to launch the app using 'nohup'. So changing

    run "cd #{current_path} && RAILS_ENV=production unicorn_rails -c config/unicorn.rb -D"
    

    to

    run "cd #{current_path} && RAILS_ENV=production nohup unicorn_rails -c config/unicorn.rb -D"
    

    did the trick for me.

    Hope this helps somebody - it was quite a pain to figure out!

    0 讨论(0)
  • 2020-12-02 12:41

    I had this problem running rake db:create. This page clued me into the DNS issue. I checked my VPN connection and found it was disconnected for some reason. I reconnected and now rake worked without a hitch.

    0 讨论(0)
  • 2020-12-02 12:42

    The error occurs when the DNS resolution fails. Check if you can wget (or curl) the api url from the command line. Changing the DNS server and testing it might help.

    0 讨论(0)
  • 2020-12-02 12:45

    I got the same error when I check the localhost is set in hosts file it is somehow not set. Setting localhost to 127.0.0.1 solved it.

    sudo vi /etc/hosts
    >>
    
    127.0.0.1       localhost
    
    0 讨论(0)
提交回复
热议问题