Example addresses (203.0.113.0/24), not real exits
01 / 12The short answer: Transport.Proxy
A short guide to Transport.Proxy: where the login goes, how SOCKS5 works in the standard library, and why keep-alive decides when a rotating IP changes.
01
The short answer: Transport.Proxy
Go's http.Transport has a Proxy field. The Go source says the proxy type follows the URL scheme: http, https, socks5 and socks5h are supported, a missing scheme means http, and a username and password in the URL are sent to the proxy (as a Proxy-Authorization header for HTTP proxies). No extra package is needed for SOCKS5.
Building the URL with url.UserPassword has one benefit over pasting LOGIN:PASSWORD into a string: characters such as @ or : in a password are escaped for you.
Same client, SOCKS5 scheme and port 3333. In the Go source, socks5 is treated the same as socks5h: the target name is resolved by the proxy.
04
Environment variables
http.DefaultTransport uses http.ProxyFromEnvironment, which reads HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the lower-case names) and picks the one that matches the request scheme. A request to localhost is never proxied. Once you set Transport.Proxy yourself, the variables are no longer consulted for that client.
http.ProxyURL, by its documentation, returns a function that always gives the same URL, so every request on that client uses that one gateway.
A Transport keeps idle connections and reuses them; the default for MaxIdleConnsPerHost is 2. On a rotating gateway the IP is chosen when a connection is opened, so requests that ride one reused connection leave from the same IP. DisableKeepAlives makes the Transport use a connection for a single request only.
// A new connection for every request: on a rotating gateway this asks for a new IP each time
fresh := &http.Client{Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL),
DisableKeepAlives: true,
}}
// One shared client: connections are kept and reused, so the IP stays the same while they live
kept := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
Use the fresh client when each request should ask for a new IP, the kept client when a group of requests must stay on one IP. Test with ipinfo.io before relying on either.
07
Proxy URL schemes in net/http
Proxy URL schemes in net/http
Item
Port on proxy.proxy302.com
How the login reaches the proxy
http://
2222
Username and password from the URL go in a Proxy-Authorization header
socks5:// or socks5h://
3333
Username and password from the URL are used in the SOCKS5 login step
No scheme
Treated as http, so use 2222
Same as http://
From the comment on Transport.Proxy and the SOCKS5 branch in net/http transport.go, read on 20 November 2026; ports from Proxy302 product facts.
Each snippet needs four values from a Proxy302 proxy: host, port, login and password. For scraping, rotating residential traffic is billed per GB (Budget line US$1.50 per GB, Premium line US$5 per GB); HTTP is on port 2222 and SOCKS5 on port 3333 of proxy.proxy302.com, and the same login works for both. Without a session, each new connection gets a new IP, and a connection you keep open keeps its IP.
When the other side needs one fixed address, a datacenter IP lease costs US$0.25 for 1 day or US$3.99 for 30 days, and you choose HTTP or SOCKS5 when you buy it. There is no free trial; the smallest purchase is 1 GB of rotating residential traffic or one IP for one day.
Open the rotating residential page, choose the line, then click Review cost and generate. For a fixed IP, buy a datacenter IP on the datacenter pay-per-IP page instead.
Step 2
Open My assets and copy HOST, PORT, USERNAME and PASSWORD exactly as they are shown there.
Step 3
Paste them into the code in this guide, using the port that matches the protocol: 2222 for HTTP, 3333 for SOCKS5.
Step 4
Run the code against https://ipinfo.io/json and check that the country and org fields describe the proxy, not your own connection.
Check LOGIN and PASSWORD are exactly as in My assets; the login is in the proxy URL, not set with Request.SetBasicAuth, which would address the target site.
Fix Move the credentials into the proxy URL with url.UserPassword.
Stop when If curl with the same login also returns 407, contact Support with the order number.
proxyconnect tcp: dial tcp ... connect: connection refused, or a timeout
Check HTTP scheme with port 2222, or socks5 with port 3333; HOST copied correctly.
Fix Fix the scheme and port pair, then run again; see the connection guide for the other checks.
Stop when If all ports time out from your network, test from another network before changing code.
ipinfo shows your own IP
Check The Transport was built without Proxy, or a different client is used for the request; NO_PROXY matches the host.
Fix Use the client you configured for the call and print the Transport settings.
Stop when If DefaultTransport is used by a library, give that library your client instead of relying on variables.
FAQ
How do I set a proxy in Go without environment variables?
Set Transport.Proxy to http.ProxyURL(proxyURL) on the http.Transport you give to http.Client. The documentation says ProxyURL returns a function that always returns the same URL.
Where do the proxy username and password go?
In the proxy URL, for example through url.UserPassword. The Go source says a userinfo part in the proxy URL is passed on as the proxy login.
Does Go support SOCKS5 proxies in net/http?
Yes. The Transport.Proxy comment lists socks5 and socks5h, and the source contains a SOCKS5 username and password step, so no extra package is needed for a plain SOCKS5 proxy.
Why do several requests leave from the same IP on a rotating proxy?
They share a keep-alive connection, and the IP is chosen when the connection opens. Create a Transport with DisableKeepAlives set to true, or a new client, when you want a new connection.
Read on 20 November 2026: the comment on Transport.Proxy (schemes http, https, socks5, socks5h; userinfo sent as Proxy-Authorization), ProxyFromEnvironment (HTTP_PROXY, HTTPS_PROXY, NO_PROXY, localhost exception), DisableKeepAlives, DefaultMaxIdleConnsPerHost = 2, and the SOCKS5 username and password branch.
Read on 20 November 2026: ProxyFromEnvironment, ProxyURL ("always returns the same URL") and DefaultMaxIdleConnsPerHost.
Proxy302 product facts and price list
Product observation · Confirmed on:
Product facts file of the site (values checked against the console, the backend and the price table): products, prices in US$ (1 PTC = US$1), lease terms, protocols and ports, quantity limits, no free trial.
Ready to try it?
Create an account, top up once, then pick rotating residential, static ISP or datacenter IPs and have one running in your browser within minutes.