Sous proxy / Integrations / Go net/http

Proxy in Go: net/http without dependencies

The standard net/http handles both HTTP and SOCKS5 with a password. You just set the proxy URL in the Transport.

HTTPHTTPSSOCKS5Login and passwordRotation and sticky
Go net/http · proxy
http.ProxyURL(proxyURL)
http://LOGIN:PASSWORD@HOST:PORT
socks5://LOGIN:PASSWORD@HOST:PORT
15 * time.Second
✓ IP: Germany, residentialRun

Why use a proxy in Go net/http

net/http is the HTTP client from Go's standard library. The proxy is set in the Proxy field of http.Transport, usually via http.ProxyURL. The http, https, socks5 and socks5h schemes are supported; login and password come from the URL.

What to pick

Both HTTP and SOCKS5 work with a password without extra packages. For services with many requests enable rotation. For flows with a session on a site, sticky.

Residential

from $0.6 / GB

Home ISP addresses. The main choice for accounts and protected sites.

VIP

$2 / GB

Hand-picked clean IPs, faster and more stable than regular residential.

Mobile

$4 / GB

Carrier IPs, for platforms that check addresses strictly.

Step-by-step setup

Button names are given exactly as they appear in Go net/http.

  1. Set up the project

    Create a folder, run go mod init proxyip and save the example as main.go. No external modules needed.

  2. Export the proxy

    Take login:pass@ip:port in @SousProxyBot or the dashboard and add the http:// or socks5:// scheme.

  3. Parse the URL

    url.Parse turns the string into a *url.URL. Go sends the login and password from it to the proxy by itself.

  4. Attach the Transport

    Create an http.Client with Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}.

  5. Run and check the IP

    Run go run main.go. The console shows JSON with the proxy IP.

Code example

Put in your own HOST, PORT, LOGIN and PASSWORD from the bot or the dashboard.

go
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"time"
)

func main() {
	// SOCKS5: "socks5://LOGIN:PASSWORD@HOST:PORT"
	proxyURL, err := url.Parse("http://LOGIN:PASSWORD@HOST:PORT")
	if err != nil {
		panic(err)
	}

	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
		Timeout:   15 * time.Second,
	}

	resp, err := client.Get("https://api.ipify.org?format=json")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}

Tested by running it

We ran this example ourselves: Go 1.24.7 · net/http. Real output below, IP hidden.

Terminal · main.go
$ go run main.go
{"ip":"proxy IP"}

And this is the response when the password is wrong:

$ go run main.go
…
goroutine 1 [running]:
main.main()
	/home/user/proxy-test/main.go:25 +0x228
exit status 2

Common errors

The issues people most often bring to support.

!

proxyconnect tcp: ... 407 Proxy Authentication RequiredThe login or password was rejected. If the password has special characters, build the URL with url.UserPassword instead of string concatenation.

!

Requests go without a proxyhttp.DefaultClient or your own Transport without a Proxy field is used. Pass your client to all calls.

!

Proxy works in one place but not anotherhttp.ProxyFromEnvironment reads HTTP_PROXY and NO_PROXY. With http.ProxyURL environment variables are ignored.

!

Timeouts with rotationSome IPs are slower. Keep a sensible Client.Timeout and retry on error.

Need a proxy for Go net/http?

Residential, VIP and mobile IPs. HTTP and SOCKS5, pay per GB, 1 GB free to try.

FAQ

Do I need golang.org/x/net/proxy for SOCKS5?

Not for http.Client: net/http supports socks5 in the Proxy field itself. x/net/proxy is useful for raw TCP over SOCKS.

Where is DNS resolved with socks5?

Go treats socks5 like socks5h: the site name goes to the proxy. Check on /en/tools/dns-leak-test/.

How do I use different proxies for different requests?

The Proxy field is a function of the request. You can return a different URL depending on req.URL.Host.