{"record":{"id":"a1fed468ec16f636","repo":"gatsbyjs/gatsby","slug":"page-for-pathname-not-found","errorCode":null,"errorMessage":"Page for \"${pathName}\" not found","messagePattern":"Page for \"(.+?)\" not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/utils/page-ssr-module/entry.ts","lineNumber":152,"sourceCode":"    let findMetaActivity: MaybePhantomActivity\n    try {\n      if (getDataWrapperActivity) {\n        findMetaActivity = reporter.phantomActivity(\n          `Finding details about page and template`,\n          {\n            parentSpan: getDataWrapperActivity.span,\n          }\n        )\n        findMetaActivity.start()\n      }\n      potentialPagePath = getPagePathFromPageDataPath(pathName) || pathName\n\n      // 1. Find a page for pathname\n      const maybePage = findEnginePageByPath(potentialPagePath)\n\n      if (!maybePage) {\n        // page not found, nothing to run query for\n        throw new Error(`Page for \"${pathName}\" not found`)\n      }\n\n      page = maybePage\n\n      // 2. Lookup query used for a page (template)\n      templateDetails = INLINED_TEMPLATE_TO_DETAILS[page.componentChunkName]\n      if (!templateDetails) {\n        throw new Error(\n          `Page template details for \"${page.componentChunkName}\" not found`\n        )\n      }\n    } finally {\n      if (findMetaActivity) {\n        findMetaActivity.end()\n      }\n    }\n\n    const executionPromises: Array<Promise<any>> = []","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/utils/page-ssr-module/entry.ts#L134-L170","documentation":"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.","triggerScenarios":"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.","commonSituations":"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`.","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."],"exampleFix":"// before: requesting /blog/post-that-was-never-created\n// after (gatsby-node.js): ensure createPage runs for every slug\nexports.createPages = async ({ graphql, actions }) => {\n  const { data } = await graphql(`{ allMarkdownRemark { nodes { fields { slug } } } }`)\n  data.allMarkdownRemark.nodes.forEach(node => {\n    actions.createPage({ path: node.fields.slug, component: require.resolve('./src/templates/post.js'), context: { slug: node.fields.slug } })\n  })\n}","handlingStrategy":"validation","validationCode":"// Before serving SSR/DSG, confirm the path is a known page\nimport path from 'path'\nconst known = new Set(pages.map(p => p.path))\nfunction isKnownPage(reqPath: string): boolean {\n  return known.has(reqPath) || known.has(reqPath.replace(/\\.page-data\\/.*$/, ''))\n}","typeGuard":null,"tryCatchPattern":"try {\n  await getData({ pathName, ... })\n} catch (e) {\n  if (String(e?.message ?? e).includes('not found')) return res.status(404).send('Not found')\n  throw e\n}","preventionTips":["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."],"tags":["ssr","dsg","page-data","runtime","datastore"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}