BEST-WEB-TOOLS Blog

My own blog posts about development, tech, finance and other (interesting) stuff.

❮❮ back

2022-01-22, Dev, Guzzle, PHP, Proxy, Socks5

Strange Error with Guzzle and Socks5 Proxy

Ever tried to request a website with guzzle via a socks5 proxy and got a strange message, that you cannot connect do a local ip address?

guzzle cURL error 7: "Can't complete SOCKS5 connection to 127.0.0.1:443"

You wondered why you even tried to connect to 127.0.0.1 because you have everything right in your proxy url and everything else looks okay too. After looking around in the wide internet I found one post that gives me the right hint. socks5 vs. socks5h.

socks5://123.123.123.123:1234

Normal proxy socks5 server addresses starts with a socks5:// and in all examples you will find this addresses, but it turns out, that can go wrong if you local dns has problems because of wrong config or pollution. In my case the hostname resolved to a local ip address and that was the reason for the error. But there is a simple solution: Use socks5h://

socks5h://123.123.123.123:1234

The differance between socks5 and socks5h is that one resolves the domain name via proxy and the other via local dns. The same is available for socks4:// and socks4a://


❮❮ back