Use a residential proxy in Go with net/http: Transport.Proxy and a first check

Configure Go with net/http with separate residential proxy host and credentials, then run one authorized request. Includes fake placeholders, checks, and troubleshooting.

This guide connects Go with net/http to a residential proxy and verifies one authorized request. Copy the actual protocol, host, port, username, and password from the console. The values below are deliberately fake: host proxy.example.invalid, port 10000, username USER_EXAMPLE, password PASS_EXAMPLE_NOT_REAL. Not for mainland China.

Choose rotating residential for changing exits and traffic billing, or static residential when one exit must stay fixed for the order term. A sticky session is not a static IP.

Map the console fields

Console valueExampleWhere it goes
ProtocolHTTPThe proxy URL scheme or client proxy type
Host and portproxy.example.invalid and 10000The gateway address, without credentials
Username and passwordUSER_EXAMPLE and PASS_EXAMPLE_NOT_REALSeparate authentication fields

Create an http.Transport, set Proxy to http.ProxyURL, and attach credentials with url.UserPassword. Keep host, port, username, and password as separate values.

Minimal example

package main

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

func main() {
    proxyURL := &url.URL{Scheme: "http", Host: "proxy.example.invalid:10000"}
    proxyURL.User = url.UserPassword("USER_EXAMPLE", "PASS_EXAMPLE_NOT_REAL")

    client := &http.Client{
        Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
        Timeout: 30 * time.Second,
    }
    resp, err := client.Get("https://example.com/")
    if err != nil { panic(err) }
    defer resp.Body.Close()
    fmt.Println(resp.Status)
}

The standard library is enough for this path. Reuse one client instead of creating a new transport for every request. The target in the snippet is only a connectivity placeholder; replace it with a page you are authorized to access. For a source-IP check, use an approved endpoint that displays the request IP.

First-check sequence

ResultMeaningNext step
2xx or expected target responseThe route workedConfirm the observed exit and region
HTTP 407Proxy authentication failedRe-copy auth; do not move credentials into the host
Timeout / connection refusedRoute, protocol, port, firewall, or target issueCompare with curl testing and use a finite timeout
Unexpected region or changing exitSelection or session mismatchCheck the console parameters; use static if the order term needs one IP

For field shapes, see proxy format, HTTP / SOCKS5 setup, Docs quickstart, and 407 / timeout troubleshooting.

FAQ

What does HTTP 407 mean?

The gateway reached your client but rejected or did not receive proxy authentication. Re-copy the username and password from the console and keep them in the authentication fields.

Why does the request time out?

Check protocol, host, port, local firewall, DNS, and the authorized target. Then reduce the test to one request with a finite timeout.

Should the host include the protocol?

No. Keep the host as a hostname. Add the scheme only where the library expects a proxy URL.

Can I use SOCKS5 with this exact example?

Not necessarily. This Go with net/http example demonstrates an HTTP proxy. Use the protocol returned by the console and the library-specific SOCKS adapter when required.

How do I confirm the exit?

Request an authorized page that reports the source IP, compare it with your intended region or static order, and do not treat a gateway hostname as the exit.

Can a sticky session replace a static IP?

No. Sticky keeps a rotating exit for a limited window when available; a static residential order keeps its assigned exit for the order term.

May I use these placeholder credentials?

No. The example domain cannot resolve and every credential shown here is fake. Copy current values from the console.

Can I use this in mainland China?

No. ZTProxy proxy services are not supported for use in mainland China. Use only lawful, authorized targets.

Next steps

  1. Copy the current gateway and auth from the console.
  2. Run the example against one authorized target.
  3. Confirm the exit, then add retries and concurrency gradually. Compare other clients: Python, Node.js and Axios, and PHP and Guzzle.