Scroll up the build output to the first error. Gatsby usually names the step that failed (sourcing data, creating pages, running GraphQL queries, building HTML) and the file. The common causes are a data source failing (an API or CMS returning errors or changed fields), a bug in gatsby-node.js, a plugin incompatible with your Gatsby version, browser-only code during HTML generation, or a different Node.js version. Gatsby's docs suggest adding console.log to your build code to see what's happening.
What's the problem
gatsby build fails locally or on your host, often with "Building static HTML failed", a GraphQL error, or a plugin error.
Why it happens
- A data source failing: a CMS or API down, a wrong token, or a field renamed.
- A bug in
gatsby-node.jsor page creation code. - GraphQL queries asking for fields that no longer exist.
- Browser-only code (
window,document) running during static HTML generation. - Plugin or Node.js version mismatches.
- Out of memory on large sites.
How to fix it
- Find the first error and the step and file it names.
- For data sourcing, check the CMS or API and its token.
- For GraphQL errors, check the fields still exist in your data.
- For "Building static HTML failed", find the browser-only code and guard it.
- Add
console.login your build code to see values. - Match Node.js and plugin versions to what your Gatsby version supports.
What Preventionlabs checks
One click runs the full report on your domain. For this problem it shows whether your site loads, how fast, and where its redirects go. With Cloudflare connected, it also shows recent deploys and account changes, with their times. It doesn't read your server logs, so the exact error message is in your host's logs.
Run your free reportYour first report is free, no card needed. Then A$50 a month, up to 10 domains. Read-only: it never changes anything.
Sources
- Gatsby: Debugging the Build Processofficial docs
One of the fastest ways to gain insight into Gatsby’s build process is using the console functionality built into Node.js .
Preventionlabs is independent and not affiliated with Gatsby. Product names are used only to describe the problem.
← All of Frameworks