gatsbyjs/gatsby · error

Image downloading failed for ${originalImg}, please check if

Error message

Image downloading failed for ${originalImg}, please check if the image still exists on contentful

What it means

In gatsby-remark-images-contentful (index.js:71-83), the plugin downloads images from Contentful's CDN using axios GET with responseType 'stream'. If the HTTP request fails (network error, 404, 403, DNS failure, timeout), the catch block calls reporter.panic with the image URL and the axios error. The image URL is derived from the markdown AST node.url, with a 'https:' prefix prepended if the URL doesn't start with http/https. After downloading, the stream is piped to sharp for metadata extraction.

Source

Thrown at packages/gatsby-remark-images-contentful/src/index.js:78

    const cacheKey = `remark-images-ctf-${node.url}-${optionsHash}`
    const cachedRawHTML = await cache.get(cacheKey)

    if (cachedRawHTML) {
      return cachedRawHTML
    }
    const sharp = await getSharpInstance()
    const metaReader = sharp()

    // @todo to increase reliablility, this should use the asset downloading function from gatsby-source-contentful
    let response
    try {
      response = await axios({
        method: `GET`,
        url: originalImg, // for some reason there is a './' prefix
        responseType: `stream`,
      })
    } catch (err) {
      reporter.panic(
        `Image downloading failed for ${originalImg}, please check if the image still exists on contentful`,
        err
      )
      return []
    }

    response.data.pipe(metaReader)

    let metadata
    try {
      metadata = await metaReader.metadata()
    } catch (error) {
      console.log(error)
      reporter.panic(
        `The image "${node.url}" (with alt text: "${node.alt}") doesn't appear to be a supported image format.`,
        error
      )
    }

View on GitHub (pinned to 8b06340921)

Solutions

  1. Verify the image URL from the error message is accessible: curl -I <url>
  2. Check Contentful: ensure the asset is published and exists in the target environment
  3. Remove or update the markdown reference to the deleted image
  4. For CI environments: ensure network access to Contentful CDN (images.ctfassets.net)
  5. If rate-limited, reduce parallel image processing or add retries

Example fix

// before: markdown references a deleted Contentful image
![Alt text](//images.ctfassets.net/space/asset/deleted-image.png)

// after: update to a valid asset or remove the reference
![Alt text](//images.ctfassets.net/space/asset/existing-image.png)
Defensive patterns

Strategy: retry

Validate before calling

// Pre-build: validate all Contentful image URLs in markdown are reachable
const axios = require('axios')

async function validateContentfulImages(urls) {
  for (const url of urls) {
    try {
      await axios.head(url)
    } catch (err) {
      console.error(`Contentful image unreachable: ${url} — ${err.message}`)
    }
  }
}

Try / catch

// If you control the markdown processing, wrap image fetching with retry:
async function fetchWithRetry(url, retries = 3) {
  for (let i = 0; i < retries; i++) {
    try {
      return await axios({ method: 'GET', url, responseType: 'stream' })
    } catch (err) {
      if (i === retries - 1) throw err
      const delay = Math.pow(2, i) * 1000
      await new Promise(r => setTimeout(r, delay))
    }
  }
}

Prevention

When it happens

Trigger: A Contentful image asset was deleted or unpublished after being referenced in markdown. Network connectivity issues during build. Contentful CDN returns 404/403 for the asset URL. DNS resolution failure. Build running in an environment without internet access. Rate limiting from Contentful CDN.

Common situations: Contentful asset deleted but markdown still references it. Build in CI without network access or behind a firewall. Contentful space/environment mismatch where assets exist in one environment but not another. Stale build cache referencing old asset URLs after content migration.

Related errors


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