getaddrinfo: nodename nor servname provided, or not known

前端 未结 13 1622
梦谈多话
梦谈多话 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: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!

提交回复
热议问题