gatsbyjs/gatsby · critical

Incompatible DSG/SSR executing environment. Function was bui

Error message

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}

What it means

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.

Source

Thrown at packages/gatsby/src/schema/graphql-engine/platform-and-arch-check.ts:5

if (
  process.env.GATSBY_FUNCTIONS_PLATFORM !== process.platform ||
  process.env.GATSBY_FUNCTIONS_ARCH !== process.arch
) {
  throw new Error(
    `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}".` +
      (process.env.gatsby_executing_command === `serve`
        ? `\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\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}`
  )
}

View on GitHub (pinned to 8b06340921)

Solutions

  1. Rebuild for the runtime host: `gatsby build --functions-platform=${platform} --functions-arch=${arch}` (or set GATSBY_FUNCTIONS_PLATFORM / GATSBY_FUNCTIONS_ARCH to match).
  2. 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').
  3. Build inside the same base image/environment you will serve from (e.g. the production linux container).
  4. Drop the cross-target flags entirely if you intend to serve on the build host.

Example fix

# before - built for linux, serving on macOS/darwin
GATSBY_FUNCTIONS_PLATFORM=linux GATSBY_FUNCTIONS_ARCH=x64 gatsby build
gatsby serve # throws
# after - rebuild for the serving host
gatsby build --functions-platform=darwin --functions-arch=arm64
gatsby serve
Defensive patterns

Strategy: validation

Validate before calling

// Assert build-time and runtime platform match before serve/deploy.
const builtPlatform = process.env.GATSBY_FUNCTIONS_PLATFORM
const builtArch = process.env.GATSBY_FUNCTIONS_ARCH
if (builtPlatform && builtArch && (builtPlatform !== process.platform || builtArch !== process.arch)) {
  throw new Error(`Functions built for ${builtPlatform}/${builtArch} but running on ${process.platform}/${process.arch}. Rebuild for this host.`)
}

Type guard

function functionsMatchHost() {
  return process.env.GATSBY_FUNCTIONS_PLATFORM === process.platform &&
         process.env.GATSBY_FUNCTIONS_ARCH === process.arch
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/f5101a78227b42b7. Report an issue: GitHub.