{"record":{"id":"41c2a082501307b6","repo":"nats-io/nats-server","slug":"must-specify-c-config-option-to-check-config","errorCode":null,"errorMessage":"must specify [-c, --config] option to check configuration file syntax","messagePattern":"must specify \\[-c, --config\\] option to check configuration file syntax","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/opts.go","lineNumber":6403,"sourceCode":"\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif cerr, ok := err.(*processConfigErr); !ok || len(cerr.Errors()) != 0 {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t// If we get here we only have warnings and can still continue\n\t\t\tfmt.Fprint(os.Stderr, err)\n\t\t} else if opts.CheckConfig {\n\t\t\t// Report configuration file syntax test was successful and exit.\n\t\t\treturn opts, nil\n\t\t}\n\n\t\t// Call this again to override config file options with options from command line.\n\t\t// Note: We don't need to check error here since if there was an error, it would\n\t\t// have been caught the first time this function was called (after setting up the\n\t\t// flags).\n\t\tfs.Parse(args)\n\t} else if opts.CheckConfig {\n\t\treturn nil, fmt.Errorf(\"must specify [-c, --config] option to check configuration file syntax\")\n\t}\n\n\t// Special handling of some flags\n\tvar (\n\t\tflagErr     error\n\t\ttlsDisabled bool\n\t\ttlsOverride bool\n\t)\n\tfs.Visit(func(f *flag.Flag) {\n\t\t// short-circuit if an error was encountered\n\t\tif flagErr != nil {\n\t\t\treturn\n\t\t}\n\t\tif strings.HasPrefix(f.Name, \"tls\") {\n\t\t\tif f.Name == \"tls\" {\n\t\t\t\tif !opts.TLS {\n\t\t\t\t\t// User has specified \"-tls=false\", we need to disable TLS\n\t\t\t\t\topts.TLSConfig = nil","sourceCodeStart":6385,"sourceCodeEnd":6421,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/opts.go#L6385-L6421","documentation":"NATS server flag processing produces this when -check_config (check-config behavior) is requested but no configuration file was supplied via -c/--config. There is no file to parse, so syntax checking cannot proceed and ProcessConfigFile/flag handling returns this error.","triggerScenarios":"Running `nats-server -check_config` (or setting CheckConfig) without also passing `-c <file>`.","commonSituations":"CI syntax-validation scripts that forgot the config flag, docs examples where -c was dropped, or checking a server that was intentionally started without any config file.","solutions":["Run `nats-server -c /path/to/nats.conf -check_config` so there is a file to validate.","If the server legitimately runs with no config file, skip the check step.","Verify flag ordering/spelling: -c must precede or follow with its file argument in the same command."],"exampleFix":"// before\nnats-server --check_config\n// after\nnats-server -c nats.conf --check_config","handlingStrategy":"validation","validationCode":"// In CI: ensure a config file is supplied when checking syntax\nif [ -z \"$CONFIG_FILE\" ]; then echo \"-c CONFIG required with -check_config\"; exit 1; fi\nnats-server -c \"$CONFIG_FILE\" --check_config","typeGuard":"null","tryCatchPattern":"if err := validateFlags(); err != nil {\n    if strings.Contains(err.Error(), \"must specify [-c, --config]\") {\n        fmt.Fprintln(os.Stderr, \"Usage: nats-server -c <file> --check_config\")\n        os.Exit(2)\n    }\n}","preventionTips":["Always pair --check_config with an explicit -c <file>.","Script config validation with the file path as a required variable.","Remember servers may run with no config file, but the check flag requires one."],"tags":["cli","config","flags"],"backgroundTag":"missing-config-flag","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}