🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Routing••By Komal Nakrani

Fix: Astro Can't Render the Route

Fix "Astro can't render the route": restart the dev server, clear stale caches, and check pages, redirects and injected routes so every route maps to a real file.

#Astro#Errors#Routing

“Astro can’t render the route.” means Astro matched a URL to a route but found nothing behind it. The message: “Astro cannot find any content to render for this route. There is no file or redirect associated with this route.” It almost always comes from a stale dev server after you renamed, moved or deleted a page. Restart npm run dev; if it persists, check the route actually maps to a file, a redirect, or a route an integration injects.

Key Takeaways

  • The usual cause is a page renamed or deleted while the dev server was running. Restart it first.
  • Every route needs a page file in src/pages/, an entry in redirects, or an injected route.
  • Clear node_modules/.vite if a restart doesn’t help.
  • Astro 7 still lists this error, but a route with nothing behind it more often ends in a 404 now.

Fix 1: restart the dev server

Astro’s error hint says it directly: “If you expect to find a route here, this may be an Astro bug. Please file an issue/restart the dev server.” The dev server keeps a route table in memory. Renaming src/pages/about.astro to src/pages/about/index.astro, or switching branches with different pages, can leave a route pointing at a file that no longer exists.

# Terminal: stop with Ctrl+C, then
npm run dev

Fix 2: clear stale caches

If restarting doesn’t help, remove Vite’s dependency cache and Astro’s generated files, then start again:

# Terminal
rm -rf node_modules/.vite .astro
npm run dev

Both are regenerated on startup. This also helps after upgrading Astro or an integration.

Fix 3: check the route has a source

Every URL Astro serves comes from one of three places. Confirm the one you expect exists:

  1. A page file. /pricing/ needs src/pages/pricing.astro, src/pages/pricing/index.astro, or a .md/.mdx page. Dynamic routes like src/pages/blog/[slug].astro must return that slug from getStaticPaths() when prerendered.
  2. A redirect. Entries in the redirects config create routes with no file:
// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  redirects: {
    '/old-pricing': '/pricing/',
    '/blog/[...slug]': '/articles/[...slug]',
  },
});

A redirect whose destination doesn’t exist leaves visitors on a dead route. The Astro redirects tip covers the rules for dynamic redirects.

  1. An injected route. Integrations such as sitemap, Starlight or a CMS can add routes with injectRoute(). If you removed an integration’s files but left it in integrations, or the other way round, its routes can break. Check astro.config.mjs against package.json.

Fix 4: look for conflicting files

Two files claiming the same URL, such as src/pages/about.astro and src/pages/about.md, or a static and a dynamic route that overlap, confuse the route table. Run a build to see Astro’s route list and any warnings:

# Terminal
npm run build

The prerender route conflict fix explains how Astro prioritises overlapping routes, and the routing guide covers file-based routing end to end. Our pages and routing docs show the page layout used in Komal Astro themes, and the official routing docs list the priority order.

If it still fails after a clean restart with a real file behind it, run npx astro info and open an issue on the Astro GitHub repository with a minimal reproduction.

FAQ

Why does Astro say it can’t render a route that exists?

The dev server is usually holding a stale route table from before you moved or renamed the file. Restart it, and clear node_modules/.vite if needed.

Does this error happen in production builds?

Rarely. It’s mostly a dev-server problem. In a build, routes are computed fresh from your files, so a missing page shows up as a 404 rather than this error.

Can a redirect cause “Astro can’t render the route”?

A redirect defines a route without a file. If its destination is wrong or the redirect was removed while the server ran, the route can end up with nothing to render. Check the redirects config and restart.