{"record":{"id":"143993d68425117a","repo":"cloudflare/cloudflared","slug":"hostname-and-url-shouldn-t-match-see-help-for-m","errorCode":null,"errorMessage":"hostname and url shouldn't match. See --help for more information","messagePattern":"hostname and url shouldn't match\\. See --help for more information","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/cmd.go","lineNumber":247,"sourceCode":"func TunnelCommand(c *cli.Context) error {\n\tsc, err := newSubcommandContext(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Run an adhoc named tunnel\n\t// Allows for the creation, routing (optional), and startup of a tunnel in one command\n\t// --name required\n\t// --url or --hello-world required\n\t// --hostname optional\n\tif name := c.String(cfdflags.Name); name != \"\" {\n\t\thostname, err := validation.ValidateHostname(c.String(\"hostname\"))\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"Invalid hostname provided\")\n\t\t}\n\t\ttunnelURL := c.String(\"url\")\n\t\tif tunnelURL == hostname && tunnelURL != \"\" && hostname != \"\" {\n\t\t\treturn fmt.Errorf(\"hostname and url shouldn't match. See --help for more information\")\n\t\t}\n\n\t\treturn runAdhocNamedTunnel(sc, name, c.String(CredFileFlag))\n\t}\n\n\t// Run a quick tunnel\n\t// A unauthenticated named tunnel hosted on <random>.<quick-tunnels-service>.com\n\tshouldRunQuickTunnel := c.IsSet(\"url\") || c.IsSet(ingress.HelloWorldFlag)\n\tif c.String(\"quick-service\") != \"\" && shouldRunQuickTunnel {\n\t\treturn RunQuickTunnel(sc)\n\t}\n\n\t// If user provides a config, check to see if they meant to use `tunnel run` instead\n\tif ref := config.GetConfiguration().TunnelID; ref != \"\" {\n\t\treturn fmt.Errorf(\"use `cloudflared tunnel run` to start tunnel %s\", ref)\n\t}\n\n\t// Classic tunnel usage is no longer supported","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/cmd.go#L229-L265","documentation":"When running an ad-hoc named tunnel via 'cloudflared tunnel run', the --hostname and --url flags must not be identical, because that would map the tunnel to itself and create a nonsensical route. The pre-flight check in TunnelCommand rejects this configuration.","triggerScenarios":"Running e.g. `cloudflared tunnel run --hostname localhost --url localhost <name>` — tunnelURL == hostname, both non-empty.","commonSituations":"Copy-pasting the same value into both flags, misunderstanding that --hostname is the public ingress hostname (e.g. app.example.com) while --url is the local origin service (e.g. http://localhost:8080).","solutions":["Set --hostname to the public DNS name and --url to the local origin address; they must differ","Omit --hostname if you only want a local origin run without routing","Review `cloudflared tunnel run --help` for flag semantics"],"exampleFix":"# before\ncloudflared tunnel run --hostname localhost --url localhost mytunnel\n# after\ncloudflared tunnel run --hostname app.example.com --url http://localhost:8080 mytunnel","handlingStrategy":"validation","validationCode":"hostname, _ := validation.ValidateHostname(hostnameFlag)\nif urlFlag != \"\" && hostname != \"\" && urlFlag == hostname {\n\treturn errors.New(\"--hostname and --url must differ\")\n}","typeGuard":null,"tryCatchPattern":"if err := TunnelCommand(ctx, sc, c); err != nil {\n\tif strings.Contains(err.Error(), \"hostname and url shouldn't match\") {\n\t\t// fix flags: --hostname is public name, --url is local origin\n\t}\n\treturn err\n}","preventionTips":["Treat --hostname as the public ingress name and --url as the local service address","Never pass the same value to both flags","Verify flags in wrapper scripts before invoking cloudflared tunnel run"],"tags":["cli","config","tunnel","flags"],"backgroundTag":"conflicting-config-options","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}