{"record":{"id":"42ed3457ebc5b412","repo":"grafana/k6","slug":"couldn-t-load-the-configuration-from-q-w","errorCode":null,"errorMessage":"couldn't load the configuration from %q: %w","messagePattern":"couldn't load the configuration from %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/config.go","lineNumber":148,"sourceCode":"\n// readDiskConfig reads the configuration file from the supplied filesystem and returns it or\n// an error. The only situation in which an error won't be returned is if the\n// user didn't explicitly specify a config file path and the default config file\n// doesn't exist.\nfunc readDiskConfig(gs *state.GlobalState) (Config, error) {\n\t// Try to see if the file exists in the supplied filesystem\n\tif _, err := gs.FS.Stat(gs.Flags.ConfigFilePath); err != nil {\n\t\tif errors.Is(err, fs.ErrNotExist) && gs.Flags.ConfigFilePath == gs.DefaultFlags.ConfigFilePath {\n\t\t\t// If the file doesn't exist, but it was the default config file (i.e. the user\n\t\t\t// didn't specify anything), silence the error\n\t\t\terr = nil\n\t\t}\n\t\treturn Config{}, err\n\t}\n\n\tdata, err := fsext.ReadFile(gs.FS, gs.Flags.ConfigFilePath)\n\tif err != nil {\n\t\treturn Config{}, fmt.Errorf(\"couldn't load the configuration from %q: %w\", gs.Flags.ConfigFilePath, err)\n\t}\n\tvar conf Config\n\terr = json.Unmarshal(data, &conf)\n\tif err != nil {\n\t\treturn Config{}, fmt.Errorf(\"couldn't parse the configuration from %q: %w\", gs.Flags.ConfigFilePath, err)\n\t}\n\treturn conf, nil\n}\n\n// Permissions for the on-disk config file and its containing directory.\n// The config can contain the Grafana Cloud API token (collectors.cloud.token),\n// so it must not be readable by other local users.\nconst (\n\tconfigFileMode = fs.FileMode(0o600)\n\tconfigDirMode  = fs.FileMode(0o700)\n)\n\n// writeDiskConfig serializes the configuration to a JSON file and writes it in the supplied","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/config.go#L130-L166","documentation":"Emitted by readDiskConfig when the k6 config file (default ~/.config/loadimpact/k6.json or the path given by --config) was found by Stat but could not be read via fsext.ReadFile. This is an I/O-level failure after the existence check succeeded: permission denied, a dangling symlink, a directory, or the file disappearing between Stat and Read.","triggerScenarios":"Running any k6 command with a --config path that exists but is unreadable (chmod 000, owned by another user), points at a directory, or is a broken symlink. Note: a missing default config file is silently ignored (the code nils out fs.ErrNotExist for the default path), so absence alone never triggers this.","commonSituations":"Config file permissions changed by a privileged install or a restore from backup; k6 run under a different user/service account than the one that owns the config; --config pointing to a path inside an unmounted volume; restrictive umask plus tooling that replaced the file with a directory.","solutions":["Check permissions on the path shown in the message: `ls -l <path>` and ensure the current user can read it (the file may contain a cloud token, k6 expects it 0o600)","Fix ownership/permissions: `chmod 600 <path> && chown $USER <path>`","Verify the path is a regular file: `file <path>`; replace directories/broken symlinks with a valid JSON file","If the config is not needed, remove or correct the --config flag / K6_CONFIG env var pointing at the bad path"],"exampleFix":"# before\n$ k6 run script.js --config /etc/k6/k6.json\n# error: couldn't load the configuration from \"/etc/k6/k6.json\": open /etc/k6/k6.json: permission denied\n\n# after\n$ sudo chown $USER /etc/k6/k6.json && chmod 600 /etc/k6/k6.json\n$ k6 run script.js --config /etc/k6/k6.json","handlingStrategy":"validation","validationCode":"# Guard before running k6: config path readable and a regular file\ncfg=\"${K6_CONFIG:-$HOME/.config/loadimpact/k6.json}\"\nif [ -e \"$cfg\" ]; then\n  [ -f \"$cfg\" ] && [ -r \"$cfg\" ] || { echo \"config $cfg not readable\"; exit 1; }\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep k6 config owned by the runtime user with mode 600 (it may hold a cloud token)","Avoid pointing --config at paths on flaky mounts or directories","When baking container images, chmod/chown the config in the same layer it is created"],"tags":["config","filesystem","permissions"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}