{"record":{"id":"d0086554ae7fb593","repo":"cloudflare/cloudflared","slug":"hostname-cannot-contain-a-port","errorCode":null,"errorMessage":"Hostname cannot contain a port","messagePattern":"Hostname cannot contain a port","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ingress/ingress.go","lineNumber":26,"sourceCode":"\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/pkg/errors\"\n\t\"github.com/rs/zerolog\"\n\t\"github.com/urfave/cli/v2\"\n\t\"golang.org/x/net/idna\"\n\n\t\"github.com/cloudflare/cloudflared/config\"\n\t\"github.com/cloudflare/cloudflared/ingress/middleware\"\n\t\"github.com/cloudflare/cloudflared/ipaccess\"\n)\n\nvar (\n\tErrNoIngressRules             = errors.New(\"The config file doesn't contain any ingress rules\")\n\tErrNoIngressRulesCLI          = errors.New(\"No ingress rules were defined in provided config (if any) nor from the cli, cloudflared will return 503 for all incoming HTTP requests\")\n\terrLastRuleNotCatchAll        = errors.New(\"The last ingress rule must match all URLs (i.e. it should not have a hostname or path filter)\")\n\terrBadWildcard                = errors.New(\"Hostname patterns can have at most one wildcard character (\\\"*\\\") and it can only be used for subdomains, e.g. \\\"*.example.com\\\"\")\n\terrHostnameContainsPort       = errors.New(\"Hostname cannot contain a port\")\n\tErrURLIncompatibleWithIngress = errors.New(\"You can't set the --url flag (or $TUNNEL_URL) when using multiple-origin ingress rules\")\n)\n\nconst (\n\tServiceBastion     = \"bastion\"\n\tServiceSocksProxy  = \"socks-proxy\"\n\tServiceWarpRouting = \"warp-routing\"\n)\n\n// FindMatchingRule returns the index of the Ingress Rule which matches the given\n// hostname and path. This function assumes the last rule matches everything,\n// which is the case if the rules were instantiated via the ingress#Validate method.\n//\n// Negative index rule signifies local cloudflared rules (not-user defined).\nfunc (ing Ingress) FindMatchingRule(hostname, path string) (*Rule, int) {\n\t// The hostname might contain port. We only want to compare the host part with the rule\n\thost, _, err := net.SplitHostPort(hostname)\n\tif err == nil {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/ingress/ingress.go#L8-L44","documentation":"errHostnameContainsPort is returned when an ingress rule's hostname field includes a port (e.g. 'example.com:8080'). The hostname field must be a bare hostname; the destination port belongs in the service URL, not the hostname match pattern.","triggerScenarios":"validateHostname calls net.SplitHostPort(r.Hostname) and it succeeds, meaning the hostname string contains a host:port pair such as 'app.example.com:8443'.","commonSituations":"Users porting an origin URL like 'http://app.example.com:8080' into the hostname field, or intending to match traffic on a specific port instead of setting it in the service URL.","solutions":["Strip the port from the hostname field: use 'app.example.com'","Put the port in the service URL instead, e.g. service: 'http://localhost:8080'","Re-run 'cloudflared tunnel ingress validate'"],"exampleFix":"// before\nhostname: \"app.example.com:8443\"\n// after\nhostname: \"app.example.com\"\nservice: \"https://localhost:8443\"","handlingStrategy":"validation","validationCode":"func hostnameHasPort(h string) bool { _, _, err := net.SplitHostPort(h); return err == nil }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep hostname fields bare; ports belong in the service URL","Never paste full origin URLs into the hostname field","Validate configs before running the tunnel"],"tags":["config","ingress","hostname","port"],"backgroundTag":"invalid-config-value","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}