Ruby Net::OpenTimeout: execution expired

后端 未结 3 1315
借酒劲吻你
借酒劲吻你 2021-02-20 04:53

I\'m consistently getting this error on several hosts on my machine, e.g.:

require \'open-uri\'
open(\'https://google.com\').read


Net::OpenTimeout: execution e         


        
相关标签:
3条回答
  • 2021-02-20 05:14

    I've hit another reason for this issue. Had a network where IPv6 is announced as routable but is not. That lead to IPv6 trying to be used resulting in the error.

    So I had to disable IPv6.

    For Red Hat Enterprise Linux 7:

    # cat /etc/sysctl.d/10-ipv6.conf 
    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    # sysctl -p
    

    The require 'resolv-replace' also helped but my guess is that it just resolved to IPv4 instead so I don't want to limit app in such a way.

    0 讨论(0)
  • 2021-02-20 05:19

    Looks like it's a an issue with how Ruby resolves DNS.

    Added require 'resolv-replace' and now it's opening connections immediately.

    Sources: https://stackoverflow.com/a/27485369/116925 https://github.com/ruby/ruby/pull/597#issuecomment-40507119

    0 讨论(0)
  • 2021-02-20 05:22

    I received error from rails application in docker container, and restarting docker service solved the problem:

    sudo service docker start
    
    0 讨论(0)
提交回复
热议问题