gatsbyjs/gatsby · error
Page for "${pathName}" not found
Error message
Page for "${pathName}" not found What it means
Thrown inside `getData` (the SSR/getData entrypoint) when `findEnginePageByPath(potentialPagePath)` returns nullish for an incoming request path. The GraphQL/data engine could not match the request URL to any page registered in the state store, so there is nothing to render or query data for. It is a runtime lookup failure during SSR/DSG data generation.
Source
Thrown at packages/gatsby/src/utils/page-ssr-module/entry.ts:152
let findMetaActivity: MaybePhantomActivity
try {
if (getDataWrapperActivity) {
findMetaActivity = reporter.phantomActivity(
`Finding details about page and template`,
{
parentSpan: getDataWrapperActivity.span,
}
)
findMetaActivity.start()
}
potentialPagePath = getPagePathFromPageDataPath(pathName) || pathName
// 1. Find a page for pathname
const maybePage = findEnginePageByPath(potentialPagePath)
if (!maybePage) {
// page not found, nothing to run query for
throw new Error(`Page for "${pathName}" not found`)
}
page = maybePage
// 2. Lookup query used for a page (template)
templateDetails = INLINED_TEMPLATE_TO_DETAILS[page.componentChunkName]
if (!templateDetails) {
throw new Error(
`Page template details for "${page.componentChunkName}" not found`
)
}
} finally {
if (findMetaActivity) {
findMetaActivity.end()
}
}
const executionPromises: Array<Promise<any>> = []View on GitHub (pinned to 8b06340921)
Solutions
- Verify the page was created: search your `createPage` calls in `gatsby-node.ts`/`gatsby-node.js` for the failing path.
- Regenerate the cache and datastore: `rm -rf .cache public && gatsby build` before serving.
- Ensure the deployment artifact includes the fresh `.cache/datastore` produced by the matching build.
- Add a catch-all 404 page or redirect for paths that may be requested but not generated.
Example fix
// before: requesting /blog/post-that-was-never-created
// after (gatsby-node.js): ensure createPage runs for every slug
exports.createPages = async ({ graphql, actions }) => {
const { data } = await graphql(`{ allMarkdownRemark { nodes { fields { slug } } } }`)
data.allMarkdownRemark.nodes.forEach(node => {
actions.createPage({ path: node.fields.slug, component: require.resolve('./src/templates/post.js'), context: { slug: node.fields.slug } })
})
} Defensive patterns
Strategy: validation
Validate before calling
// Before serving SSR/DSG, confirm the path is a known page
import path from 'path'
const known = new Set(pages.map(p => p.path))
function isKnownPage(reqPath: string): boolean {
return known.has(reqPath) || known.has(reqPath.replace(/\.page-data\/.*$/, ''))
} Try / catch
try {
await getData({ pathName, ... })
} catch (e) {
if (String(e?.message ?? e).includes('not found')) return res.status(404).send('Not found')
throw e
} Prevention
- Generate every route you intend to serve via `createPage`.
- Ship the datastore and page-ssr bundle from the same build.
- Add 404/redirect handling at the edge for removed pages.
When it happens
Trigger: An HTTP request hits the SSR/DSG server with a pathName that does not correspond to a created Gatsby page (e.g. `/page-data/...` whose slug was never created via `createPage`). Also fires when `getPagePathFromPageDataPath` yields a path and that path is absent from the engine's page map, or when a page was created in one build but the engine cache (`.cache/datastore`) is from another.
Common situations: Requesting an SSR/DSG route that was deleted or renamed but the CDN/proxy still routes traffic to it; mismatched `.cache` between build and serve (`gatsby build` then `gatsby serve` against a stale cache); dynamic routes whose slugs were not all enumerated by `createPage`.
Related errors
- Incompatible DSG/SSR executing environment. Function was bui
- Page "${pagePath}" doesn't exist. It might have been deleted
- Unexpected result of config factory. Expected "function", go
- Page template details for "${page.componentChunkName}" not f
- ${r.errors.join(`, `)}
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/a1fed468ec16f636.
Report an issue: GitHub.