{"record":{"id":"376e3dac7fae3232","repo":"nats-io/nats-server","slug":"can-t-specify-both-http-v-and-https-v-ports","errorCode":null,"errorMessage":"can't specify both HTTP (%v) and HTTPs (%v) ports","messagePattern":"can't specify both HTTP \\((.+?)\\) and HTTPs \\((.+?)\\) ports","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/server.go","lineNumber":3029,"sourceCode":"// DEPRECATED: Should use StartMonitoring.\nfunc (s *Server) StartHTTPMonitoring() {\n\ts.startMonitoring(false)\n}\n\n// StartHTTPSMonitoring will enable the HTTPS monitoring port.\n// DEPRECATED: Should use StartMonitoring.\nfunc (s *Server) StartHTTPSMonitoring() {\n\ts.startMonitoring(true)\n}\n\n// StartMonitoring starts the HTTP or HTTPs server if needed.\nfunc (s *Server) StartMonitoring() error {\n\t// Snapshot server options.\n\topts := s.getOpts()\n\n\t// Specifying both HTTP and HTTPS ports is a misconfiguration\n\tif opts.HTTPPort != 0 && opts.HTTPSPort != 0 {\n\t\treturn fmt.Errorf(\"can't specify both HTTP (%v) and HTTPs (%v) ports\", opts.HTTPPort, opts.HTTPSPort)\n\t}\n\tvar err error\n\tif opts.HTTPPort != 0 {\n\t\terr = s.startMonitoring(false)\n\t} else if opts.HTTPSPort != 0 {\n\t\tif opts.TLSConfig == nil {\n\t\t\treturn fmt.Errorf(\"TLS cert and key required for HTTPS\")\n\t\t}\n\t\terr = s.startMonitoring(true)\n\t}\n\treturn err\n}\n\n// HTTP endpoints\nconst (\n\tRootPath         = \"/\"\n\tVarzPath         = \"/varz\"\n\tConnzPath        = \"/connz\"","sourceCodeStart":3011,"sourceCodeEnd":3047,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/server.go#L3011-L3047","documentation":"StartMonitoring rejects configs that set both the plain HTTP monitoring port and the HTTPS monitoring port; only one monitor listener may be configured. The message includes both conflicting port values.","triggerScenarios":"Options contain both opts.HTTPPort != 0 and opts.HTTPSPort != 0, e.g. config with both `http_port: 8222` and `https_port: 8223`, or flags `-m 8222 --https_port 8223` combined.","commonSituations":"Merging two config files (one with http_port, one with https_port); flag-based overrides stacking on a config that already sets the other port; environment/templating filling both values.","solutions":["Keep only one: delete `http_port` if you want TLS monitoring, or delete `https_port` for plain HTTP","Check the effective merged config (`nats-server --signal reload` logs, or start with -V) for both keys","Audit systemd/CLI flags for a duplicate -m/--https_port"],"exampleFix":"// before\nhttp_port: 8222\nhttps_port: 8223\n// after\nhttps_port: 8223\ntls { cert: \"server.pem\", key: \"server-key.pem\" }","handlingStrategy":"validation","validationCode":"// Reject double monitoring ports before server start\nif cfg.HTTPPort != 0 && cfg.HTTPSPort != 0 {\n    return errors.New(\"configure only one of http_port or https_port for monitoring\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set exactly one of http_port / https_port in each config","When overriding via flags, unset the conflicting config key","Template monitoring config from a single variable so both ports can't be filled"],"tags":["nats-server","monitoring","configuration","port-conflict"],"backgroundTag":"invalid-resolver-configuration","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}