
Issue #21088 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Open to Assigned Assignee set to shioimm (Misaki Shioi) ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111702 * Author: dmlary (David Lary) * Status: Assigned * Assignee: shioimm (Misaki Shioi) * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [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. -- https://bugs.ruby-lang.org/