kgretzky/evilginx2 · error

proxy port can't be 0

Error message

proxy port can't be 0

What it means

setProxy requires a non-zero port when the upstream proxy is enabled. Port 0 is not a usable proxy endpoint, so configuration is rejected before the proxy URL is constructed. This is a required-field validation on the port argument.

Source

Thrown at core/http_proxy.go:1920

	pl := p.getPhishletByPhishHost(hostname)
	if pl != nil {
		sid, ok := p.ip_sids[ip_addr+"-"+pl.Name]
		return sid, ok
	}
	return "", false
}

func (p *HttpProxy) setProxy(enabled bool, ptype string, address string, port int, username string, password string) error {
	if enabled {
		ptypes := []string{"http", "https", "socks5", "socks5h"}
		if !stringExists(ptype, ptypes) {
			return fmt.Errorf("invalid proxy type selected")
		}
		if len(address) == 0 {
			return fmt.Errorf("proxy address can't be empty")
		}
		if port == 0 {
			return fmt.Errorf("proxy port can't be 0")
		}

		u := url.URL{
			Scheme: ptype,
			Host:   address + ":" + strconv.Itoa(port),
		}

		if strings.HasPrefix(ptype, "http") {
			var dproxy *http_dialer.HttpTunnel
			if username != "" {
				dproxy = http_dialer.New(&u, http_dialer.WithProxyAuth(http_dialer.AuthBasic(username, password)))
			} else {
				dproxy = http_dialer.New(&u)
			}
			p.Proxy.Tr.Dial = dproxy.Dial
		} else {
			if username != "" {
				u.User = url.UserPassword(username, password)

View on GitHub (pinned to 4c0988a1d9)

Solutions

  1. Provide the actual listening port of the upstream proxy, e.g. 8080, 9050, 1080
  2. Verify the port from your proxy provider/daemon config and re-run the proxy command with it
  3. If using env/config, ensure the port field is parsed as an integer > 0 before calling setProxy
  4. Confirm address and port order in the command: `proxy <type> <address> <port> [user] [pass]`

Example fix

// before
p.setProxy(true, "http", "proxy.example.com", 0, "", "")
// after
p.setProxy(true, "http", "proxy.example.com", 8080, "", "")
Defensive patterns

Strategy: validation

Validate before calling

if enabled && port == 0 {
    return fmt.Errorf("proxy port is required when proxy is enabled")
}

Type guard

func validProxyPort(port int) bool {
    return port > 0 && port <= 65535
}

Try / catch

if err := proxy.setProxy(true, ptype, addr, port, user, pass); err != nil {
    if strings.Contains(err.Error(), "port can't be 0") {
        return fmt.Errorf("supply the upstream proxy port, e.g. 8080")
    }
}

Prevention

When it happens

Trigger: Calling setProxy(true, "http", "proxy.example.com", 0, ...) or passing the `proxy` command with the port argument missing/zero, or a numeric config field that defaulted to 0 because it was never set.

Common situations: Forgot to specify the port after the address (e.g. typed only `proxy http 1.2.3.4`), a config template with port: 0 placeholder never filled in, or parsing a 'host:' string without the port and getting 0.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of kgretzky/evilginx2@4c0988a1d9 (2026-09-05). Data as JSON: /api/errors/e17b1d966fb289d7. Report an issue: GitHub.