{"record":{"id":"f5101a78227b42b7","repo":"gatsbyjs/gatsby","slug":"incompatible-dsg-ssr-executing-environment-functi","errorCode":null,"errorMessage":"Incompatible DSG/SSR executing environment. Function was built for \"${process.env.GATSBY_FUNCTIONS_PLATFORM}/${process.env.GATSBY_FUNCTIONS_ARCH}\" but is executing on \"${process.platform}/${process.arch}\".\\n\\nTo generate engines for \"${process.platform}/${process.arch}\" run 'gatsby build --functions-platform=${process.platform} --functions-arch=${process.arch}' or run 'gatsby build' with following envirnment variables:\\n\\nGATSBY_FUNCTIONS_PLATFORM=${process.platform}\\nGATSBY_FUNCTIONS_ARCH=${process.arch}","messagePattern":"Incompatible DSG/SSR executing environment\\. Function was built for \"(.+?)/(.+?)\" but is executing on \"(.+?)/(.+?)\"\\.\\\\n\\\\nTo generate engines for \"(.+?)/(.+?)\" run 'gatsby build --functions-platform=(.+?) --functions-arch=(.+?)' or run 'gatsby build' with following envirnment variables:\\\\n\\\\nGATSBY_FUNCTIONS_PLATFORM=(.+?)\\\\nGATSBY_FUNCTIONS_ARCH=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/gatsby/src/schema/graphql-engine/platform-and-arch-check.ts","lineNumber":5,"sourceCode":"if (\n  process.env.GATSBY_FUNCTIONS_PLATFORM !== process.platform ||\n  process.env.GATSBY_FUNCTIONS_ARCH !== process.arch\n) {\n  throw new Error(\n    `Incompatible DSG/SSR executing environment. Function was built for \"${process.env.GATSBY_FUNCTIONS_PLATFORM}/${process.env.GATSBY_FUNCTIONS_ARCH}\" but is executing on \"${process.platform}/${process.arch}\".` +\n      (process.env.gatsby_executing_command === `serve`\n        ? `\\n\\nIf you are trying to run DSG/SSR engine locally, consider using experimental utility to rebuild functions for your local platform:\\n\\nnode node_modules/gatsby/dist/schema/graphql-engine/standalone-regenerate.js`\n        : ``) +\n      `\\n\\nTo generate engines for \"${process.platform}/${process.arch}\" run 'gatsby build --functions-platform=${process.platform} --functions-arch=${process.arch}' or run 'gatsby build' with following envirnment variables:\\n\\nGATSBY_FUNCTIONS_PLATFORM=${process.platform}\\nGATSBY_FUNCTIONS_ARCH=${process.arch}`\n  )\n}\n","sourceCodeStart":1,"sourceCodeEnd":13,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/schema/graphql-engine/platform-and-arch-check.ts#L1-L13","documentation":"At runtime, the generated DSG/SSR function (the query/engine bundle) imports platform-and-arch-check, which compares the platform/arch the bundle was built for (read from GATSBY_FUNCTIONS_PLATFORM / GATSBY_FUNCTIONS_ARCH env vars baked in at build time) against the executing process.platform / process.arch. A mismatch throws because native modules (lmdb, sharp) compiled/selected for the build target cannot load on a different OS/arch. The message tells you exactly how to rebuild for the current host.","triggerScenarios":"Running `gatsby serve` or executing a generated DSG/SSR page on a host whose process.platform or process.arch differs from the values the functions were built with (the env vars GATSBY_FUNCTIONS_PLATFORM / GATSBY_FUNCTIONS_ARCH, or the --functions-platform/--functions-arch flags).","commonSituations":"Building functions for a production linux target (or on CI linux) then running `gatsby serve` locally on macOS/Windows; building on Apple Silicon (arm64) and serving on x64, or vice versa; copying a build between machines/containers of different arches; deploying functions built for one image onto another.","solutions":["Rebuild for the runtime host: `gatsby build --functions-platform=${platform} --functions-arch=${arch}` (or set GATSBY_FUNCTIONS_PLATFORM / GATSBY_FUNCTIONS_ARCH to match).","For local DSG/SSR testing after a cross-built deploy, use the included utility: `node node_modules/gatsby/dist/schema/graphql-engine/standalone-regenerate.js` (the error suggests this when gatsby_executing_command === 'serve').","Build inside the same base image/environment you will serve from (e.g. the production linux container).","Drop the cross-target flags entirely if you intend to serve on the build host."],"exampleFix":"# before - built for linux, serving on macOS/darwin\nGATSBY_FUNCTIONS_PLATFORM=linux GATSBY_FUNCTIONS_ARCH=x64 gatsby build\ngatsby serve # throws\n# after - rebuild for the serving host\ngatsby build --functions-platform=darwin --functions-arch=arm64\ngatsby serve","handlingStrategy":"validation","validationCode":"// Assert build-time and runtime platform match before serve/deploy.\nconst builtPlatform = process.env.GATSBY_FUNCTIONS_PLATFORM\nconst builtArch = process.env.GATSBY_FUNCTIONS_ARCH\nif (builtPlatform && builtArch && (builtPlatform !== process.platform || builtArch !== process.arch)) {\n  throw new Error(`Functions built for ${builtPlatform}/${builtArch} but running on ${process.platform}/${process.arch}. Rebuild for this host.`)\n}","typeGuard":"function functionsMatchHost() {\n  return process.env.GATSBY_FUNCTIONS_PLATFORM === process.platform &&\n         process.env.GATSBY_FUNCTIONS_ARCH === process.arch\n}","tryCatchPattern":null,"preventionTips":["Build and serve on the same OS/arch, or rebuild for the deploy target.","Set --functions-platform/--functions-arch explicitly in CI to match production.","For local DSG testing of a cross-build, use standalone-regenerate.js to rebuild for the local host.","Avoid copying a build between machines of different arches."],"tags":["functions","dsg","ssr","platform","native-binary","runtime"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}