{"record":{"id":"78478a61806c723a","repo":"gatsbyjs/gatsby","slug":"for-custom-ssl-https-cert-file-and-key-fil","errorCode":null,"errorMessage":"for custom ssl --https, --cert-file, and --key-file must be used together","messagePattern":"for custom ssl --https, --cert-file, and --key-file must be used together","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/commands/develop.ts","lineNumber":198,"sourceCode":"    throw e\n  }\n\n  // Run the actual develop server on a random port, and the proxy on the program port\n  // which users will access\n  const debugInfo = getDebugInfo(program)\n\n  const rootFile = (file: string): string => path.join(program.directory, file)\n\n  // Require gatsby-config.js before accessing process.env, to enable the user to change\n  // environment variables from the config file.\n  requireUncached(rootFile(`gatsby-config`))\n\n  const developPort = program.port\n\n  // In order to enable custom ssl, --cert-file --key-file and -https flags must all be\n  // used together\n  if ((program[`cert-file`] || program[`key-file`]) && !program.https) {\n    reporter.panic(\n      `for custom ssl --https, --cert-file, and --key-file must be used together`\n    )\n  }\n\n  // Check if https is enabled, then create or get SSL cert.\n  // Certs are named 'devcert' and issued to the host.\n  // NOTE(@mxstbr): We mutate program.ssl _after_ passing it\n  // to the develop process controllable script above because\n  // that would mean we double SSL browser => proxy => server\n  if (program.https) {\n    const sslHost =\n      program.host === `0.0.0.0` || program.host === `::`\n        ? `localhost`\n        : program.host\n\n    if (REGEX_IP.test(sslHost)) {\n      reporter.panic(\n        `You're trying to generate a ssl certificate for an IP (${sslHost}). Please use a hostname instead.`","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/commands/develop.ts#L180-L216","documentation":"Thrown by `gatsby develop` when the user supplies --cert-file or --key-file without also passing --https. Custom SSL requires all three flags together; omitting --https while giving a cert/key is treated as a misconfiguration and the command panics before starting the dev server.","triggerScenarios":"CLI invocation includes `--cert-file <path>` or `--key-file <path>` but `program.https` is falsy (the --https flag was not passed).","commonSituations":"Copying a partial SSL invocation from docs; assuming --cert-file implies HTTPS; scripts that pass cert/key conditionally but forget to also pass https.","solutions":["Pass all three flags together: `gatsby develop --https --cert-file ./cert.pem --key-file ./key.pem`.","If you do not want HTTPS, remove --cert-file and --key-file entirely.","Update npm scripts that build the flag list to include --https whenever cert/key are set."],"exampleFix":"// before\ngatsby develop --cert-file ./cert.pem --key-file ./key.pem\n// after\ngatsby develop --https --cert-file ./cert.pem --key-file ./key.pem","handlingStrategy":"validation","validationCode":"// Build the develop argv safely before spawning gatsby\nconst wantsCert = Boolean(argv.certFile || argv.keyFile)\nconst finalArgs = [...baseArgs]\nif (wantsCert) finalArgs.push('--https', '--cert-file', argv.certFile, '--key-file', argv.keyFile)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --https, --cert-file, --key-file as a single atomic option group.","Document the full HTTPS invocation in your package.json scripts.","Validate the flag triple in any wrapper script."],"tags":["cli","ssl","develop","https","config"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}