Actions
Bug #21088
closedTCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts
Description
TCPSocket.new
raises Socket::ResolutionError
when the connection is refused for hosts defined in /etc/hosts. It should raise Errno::ECONNREFUSED
.
[6] pry(main)> TCPSocket.new("test_system", 22)
=> #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690>
[7] pry(main)> TCPSocket.new("test_system", 12345)
Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError)
[14] pry(main)> ::Socket.getaddrinfo("test_system", nil)
=> [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)],
["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)],
["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]]
I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back.
This was not a problem in 3.3.0.
This does not happen when using localhost
This does not happen for hosts resolvable via DNS.
This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago.
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0