{"record":{"id":"3faae39a5fc387f6","repo":"caddyserver/caddy","slug":"multiple-ports-not-supported","errorCode":null,"errorMessage":"multiple ports not supported","messagePattern":"multiple ports not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/logging/netwriter.go","lineNumber":73,"sourceCode":"\t\tNew: func() caddy.Module { return new(NetWriter) },\n\t}\n}\n\n// Provision sets up the module.\nfunc (nw *NetWriter) Provision(ctx caddy.Context) error {\n\trepl := caddy.NewReplacer()\n\taddress, err := repl.ReplaceOrErr(nw.Address, true, true)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid host in address: %v\", err)\n\t}\n\n\tnw.addr, err = caddy.ParseNetworkAddress(address)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing network address '%s': %v\", address, err)\n\t}\n\n\tif nw.addr.PortRangeSize() != 1 {\n\t\treturn fmt.Errorf(\"multiple ports not supported\")\n\t}\n\n\tif nw.DialTimeout < 0 {\n\t\treturn fmt.Errorf(\"timeout cannot be less than 0\")\n\t}\n\n\treturn nil\n}\n\nfunc (nw NetWriter) String() string {\n\treturn nw.addr.String()\n}\n\n// WriterKey returns a unique key representing this nw.\nfunc (nw NetWriter) WriterKey() string {\n\treturn nw.addr.String()\n}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/logging/netwriter.go#L55-L91","documentation":"NetWriter opens exactly one connection, so Provision rejects addresses whose PortRangeSize() != 1. A port range like 'tcp/host:5000-5010' spans multiple ports and cannot map to a single dial target for a log writer.","triggerScenarios":"Configuring output net with a port range, e.g. 'net tcp/logs.example.com:2000-2010' or a placeholder expanding to a range.","commonSituations":"Copy-pasting listener address syntax (where ranges are legal) into an output address; templated configs that append ':1000-1010'.","solutions":["Change the address to a single port, e.g. 'tcp/logs.example.com:2000'","If you need multiple destinations, configure several log outputs or a relay instead of a range"],"exampleFix":"# before\noutput net tcp/logs.example.com:2000-2010\n\n# after\noutput net tcp/logs.example.com:2000","handlingStrategy":"validation","validationCode":"if a, err := caddy.ParseNetworkAddress(addr); err == nil && a.PortRangeSize() != 1 {\n    return fmt.Errorf(\"net output requires a single port, got range %s\", a.String())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember output addresses accept one port only, unlike site addresses","Lint configs for hyphenated ports in output lines"],"tags":["caddy","logging","network","ports"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}