gatsbyjs/gatsby · error

Error occurred while fetching media item #${node.databaseId}

Error message

Error occurred while fetching media item #${node.databaseId}
Media item link: ${node.link}
Edit link: ${editUrl}
File url: ${node.mediaItemUrl}

This error will fail production builds.

What it means

Error "Error occurred while fetching media item #${node.databaseId} Media item link: ${node.link} Edit link: ${editUrl} File url: ${node.mediaItemUrl} This error will fail production builds." thrown in gatsbyjs/gatsby.

Source

Thrown at packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-local-file-node.js:83

    typeof error === `string` ? error : error && error.toString()

  const { pluginOptions } = getStore().getState().gatsbyApi
  const allow404ImagesInProduction = pluginOptions.production.allow404Images
  const allow401ImagesInProduction = pluginOptions.production.allow401Images
  const errorCodeIs404 = errorString.includes(`Response code 404`)
  const errorCodeIs401 = errorString.includes(`Response code 401`)
  const errorCode = errorCodeIs404 ? `404` : errorCodeIs401 ? `401` : null

  if (
    (allow404ImagesInProduction ||
      allow401ImagesInProduction ||
      process.env.NODE_ENV !== `production`) &&
    (errorCodeIs404 || errorCodeIs401)
  ) {
    fetchState.shouldBail = true

    reporter.log(``)
    reporter.warn(
      formatLogMessage(
        `Error ${sharedError}${
          !allow404ImagesInProduction || !allow401ImagesInProduction
            ? `\n\nThis error will fail production builds.`
            : ``
        }`
      )
    )
    reporter.log(``)

    return
  }

  if (errorString.includes(`Response code 4`)) {
    reporter.log(``)

    reporter.info(
      formatLogMessage(

View on GitHub (pinned to e85d62f177)

Solutions

  1. Check whether the media URL actually returns 404/401 in a browser or curl; if the asset was deleted or made private in WordPress, restore it or remove the reference
  2. For legitimately missing assets in production, set production.allow404Images or allow401Images to true in gatsby-source-wordpress options to tolerate them
  3. Verify the WordPress URL and media files are publicly accessible (no hotlink protection, auth or CDN rule blocking server-side requests)
  4. Increase timeouts or retry after transient server errors; re-run the build once WordPress is responsive
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-local-file-node.js:83 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26). Data as JSON: /api/errors/537161d117ffb3f4. Report an issue: GitHub.