A SOCKS connection can fail locally before the proxy gets a chance to resolve the destination. Check whether your code resolved the target while constructing its socket address.

For a Java SOCKS socket, retain the target hostname with an unresolved destination address:

Proxy proxy = new Proxy(Proxy.Type.SOCKS,
    new InetSocketAddress("203.0.113.10", 1080));
Socket socket = new Socket(proxy);
socket.connect(InetSocketAddress.createUnresolved(
    "destination.example", 443), 5000);

The endpoint and hostname are placeholders; use your SOCKS5 service or a candidate from the SOCKS5 proxy list for permitted public-destination tests. The important distinction is between resolving the proxy so you can reach it and preserving the destination name for the SOCKS exchange.

Once connected, an HTTPS client still needs a TLS session for the destination hostname. A TLS wrapper should not use the proxy's hostname as the peer identity.

Also check higher-level code: a library can perform its own lookup before it calls your connector. Preserving a hostname in this socket address cannot undo a lookup performed elsewhere in the application.

Allakkat attuumassuteqartut