Astro throws “Action not found.” when a request reaches the actions handler with a name that is not exported from src/actions/index.ts. The full message is: “The server received a request for an action named <name> but could not find a match. If you renamed an action, check that you’ve updated your actions/index file and your calling code to match.” Fix it by making the calling code use exactly the key path you export in server, then run astro check to catch mismatches.
Key Takeaways
- The error name is
ActionNotFoundError; the hint suggests runningastro check.- The action name is its key path in the exported
serverobject, such asnewsletterorblog.like.- Call actions through the
actionsobject fromastro:actionsinstead of building URLs by hand.- Restart the dev server or run
astro syncafter renaming, so types and routes refresh.
What causes it
Every action call becomes a request to /_actions/<name> (or a form post with ?_action=<name>). Astro looks <name> up in the server object exported from src/actions/index.ts. If no key matches, you get this error. Common reasons:
- The action was renamed in
src/actions/index.tsbut not in the form or script that calls it. - A nested action is called by its inner name.
blog.likeis not the same aslike. - The file is in the wrong place or exports the wrong name. Astro reads
src/actions/index.ts(or.js) and itsserverexport. - A hand-written URL such as
fetch('/_actions/subscribe')or?_action=subscribehas a typo or an old name. - A stale browser tab or cached page posts to a name that no longer exists after a deploy.
The fix
Check what you actually export:
// src/actions/index.ts
import { defineAction } from 'astro:actions';
import { z } from 'astro/zod';
export const server = {
newsletter: defineAction({
accept: 'form',
input: z.object({ email: z.email() }),
handler: async ({ email }) => ({ email }),
}),
blog: {
like: defineAction({
input: z.object({ postId: z.string() }),
handler: async ({ postId }) => ({ postId }),
}),
},
};
These actions are named newsletter and blog.like. Then call them through the typed actions object, never by string:
---
// src/pages/index.astro
import { actions } from 'astro:actions';
export const prerender = false;
---
<form method="POST" action={actions.newsletter}>
<input name="email" type="email" required />
<button>Subscribe</button>
</form>
<script>
import { actions } from 'astro:actions';
document.querySelector('#like')?.addEventListener('click', async () => {
await actions.blog.like({ postId: 'hello-world' });
});
</script>
Because actions.newsletter and actions.blog.like are typed, a renamed action becomes a TypeScript error instead of a runtime 404-style failure. Run the check the hint recommends:
# Terminal
npx astro sync
npx astro check
astro sync regenerates the action types; astro check reports any call that no longer matches. If the dev server was running during a rename, restart it.
If you call actions from outside Astro
Code that is not an Astro page, such as a separate app or a test, has to use the HTTP route directly. Use the full key path joined with dots:
# Terminal
curl -X POST http://localhost:4321/_actions/blog.like \
-H "Content-Type: application/json" -d '{"postId":"hello-world"}'
When you rename an action that external callers use, keep the old key as an alias for a while so existing clients and stale tabs do not break.
Related errors
If the error says actions need server output instead, see the actions server output fix. If an action is called directly in frontmatter, see the callAction fix. Our Astro Actions guide covers the full API. The contact forms in our Astro themes are plain HTML, so this error only appears once you add actions yourself.
FAQ
What does “Action not found” mean in Astro?
The server received a call for an action name that is not a key in the server object exported from src/actions/index.ts, usually because the action was renamed or the caller uses the wrong name.
How are nested Astro actions named?
By their key path joined with dots. An action at server.blog.like is called as actions.blog.like and served at /_actions/blog.like.
Why do I get Action not found after deploying?
A page cached or open from before the deploy is calling an action name that no longer exists. Keep the old name exported temporarily, or redeploy pages and actions together.