Originally published on proxymint.
Read and write proxy strings: host:port:user:pass, user:pass@host:port, http:// vs socks5h:// URLs, separate fields, password encoding and IPv6 brackets.
TL;DR
- Four forms carry the same four values. The colon list host:port:user:pass, the authority user:pass@host:port, the full URL with a scheme, and separate server, username and password fields.
- The full URL is the portable form. curl, Python requests, Node agents, Scrapy and environment variables all parse scheme://user:pass@host:port, and the scheme picks HTTP, SOCKS5 or SOCKS5 with proxy-side DNS.
- Special characters need percent-encoding inside a URL. Write @ as %40, : as %3A, / as %2F and # as %23; separate fields take the raw password.
- IPv6 hosts go in brackets. http://user:pass@[2001:db8::1]:8080 is the only safe way to write one; the colon list cannot carry IPv6.
Key takeaways
- Store each proxy once as a full URL. Keep the password percent-encoded and generate colon lists or separate fields from that one source.
- Encode credentials separately, never the whole URL. Use quote(value, safe='') in Python and encodeURIComponent in JavaScript.
- Use socks5h:// or an http:// proxy when location matters. Plain socks5:// resolves the target name on the client's own machine.
- Give Playwright and Puppeteer separate fields. Playwright drops credentials written inside server and refuses SOCKS5 with a username, so authenticated browsers use the HTTP endpoint.
- Read the error before changing the string. A parse error means a malformed string, a 407 means wrong credentials, and a refused connection means the wrong host, port or scheme.
Read the full guide on proxymint, with the commands, tables and sources.
Top comments (0)