caddyserver/caddy · error

port %d is out of range

Error message

port %d is out of range

What it means

Error "port %d is out of range" thrown in caddyserver/caddy.

Source

Thrown at caddyconfig/httpcaddyfile/addresses.go:416

			host, port, err = net.SplitHostPort(hostSplit[0] + ":")
			if err != nil {
				host = hostSplit[0]
			}
		}
		a.Host = host
		a.Port = port
	}
	if len(hostSplit) == 2 {
		// all that remains is the path
		a.Path = "/" + hostSplit[1]
	}

	// make sure port is valid
	if a.Port != "" {
		if portNum, err := strconv.Atoi(a.Port); err != nil {
			return Address{}, fmt.Errorf("invalid port '%s': %v", a.Port, err)
		} else if portNum < 0 || portNum > 65535 {
			return Address{}, fmt.Errorf("port %d is out of range", portNum)
		}
	}

	return a, nil
}

// String returns a human-readable form of a. It will
// be a cleaned-up and filled-out URL string.
func (a Address) String() string {
	if a.Host == "" && a.Port == "" {
		return ""
	}
	scheme := a.Scheme
	if scheme == "" {
		if a.Port == strconv.Itoa(certmagic.HTTPSPort) {
			scheme = "https"
		} else {
			scheme = "http"

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Specify a port within the valid range 0-65535.
  2. Check the address for a typo such as an extra digit in the port.

When it happens

Trigger: Thrown at caddyconfig/httpcaddyfile/addresses.go:416 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/d51fbd2994a38d55. Report an issue: GitHub.