How to fix EdgeFunctionError: Function not found in Supabase
This error occurs when a request is sent to a Supabase Edge Function that doesn't exist, hasn't been deployed, or the URL is incorrect. It typically returns a 404 HTTP response with error code EF002.
Quick fix
Fixes EF002
# List your edge functions
ls -la supabase/functions/- Verify the function folder exists and has correct naming
- Deploy or redeploy the function
- Test the function locally first
- Verify the correct endpoint URL format
# List your edge functionsls -la supabase/functions/EdgeFunctionError: Function not found
What this error means
Supabase Edge Functions are serverless functions built on Deno that run in response to HTTP requests. When you invoke a function using its URL endpoint, Supabase's routing system must locate and execute the corresponding function code. The "Function not found" error means the routing system couldn't find a deployed function matching your request URL. This can happen for several reasons: the function name in your URL doesn't match the deployed function folder name, the function hasn't been successfully deployed, the endpoint URL is malformed, or the function was deleted after deployment.
Typical symptoms
- HTTP 404 response with message 'Requested function was not found'
- Error code EF002 in response body
- Function works locally with 'supabase functions serve' but fails when deployed
- Function invocation returns 'Function not found' despite being listed as ACTIVE in dashboard
- Requests to the function endpoint consistently fail with 404 errors
Common causes
- Function name in the URL doesn't match the folder name in supabase/functions/ directory
- Function hasn't been deployed yet or deployment failed silently
- Function was deployed but deployment used wrong function name or path
- Using incorrect or outdated endpoint URL format
- Function was deployed to wrong Supabase project or branch
- Attempting to call function before the deploy command completed
- Using npm packages with compatibility issues between local and deployed environments
How to fix "EdgeFunctionError: Function not found"
Check that the function folder name in your supabase/functions/ directory matches exactly what you're calling in your URL.
# List your edge functions
ls -la supabase/functions/If your folder is named send_email, the URL must be:
https://<project-ref>.supabase.co/functions/v1/send_emailFunction names are case-sensitive. Function folder names should use underscores, not hyphens.
Use the Supabase CLI to deploy the function. Make sure you're logged in and targeting the correct project:
# Deploy a specific function
supabase functions deploy <function-name>
# Or deploy all functions
supabase functions deploy
# Verify deployment succeeded
supabase functions listYour output should show the function with status ACTIVE. If deployment fails, check the error message for clues about syntax errors or missing dependencies.
Before deploying, test the function locally using the Supabase CLI:
# Start local Supabase environment
supabase start
# Serve edge functions locally
supabase functions serve
# In another terminal, call the function
curl http://localhost:54321/functions/v1/<function-name>This helps identify issues before deployment. If the function works locally but fails when deployed, the problem is likely environmental (missing npm packages, dependency issues, etc.).
Ensure you're using the correct URL format:
// Correct format
https://<your-project-ref>.supabase.co/functions/v1/<function-name>
// Example
https://example-abc123.supabase.co/functions/v1/send_email
// Call from JavaScript
const response = await fetch(
'https://example-abc123.supabase.co/functions/v1/send_email',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: 'user@example.com' }),
}
);Your project reference is visible in your Supabase dashboard under Project Settings > General > Project Ref.
If your function uses npm packages, they might work locally but fail when deployed. Some packages with native dependencies or browser-specific code won't work in Deno:
// supabase/functions/my-function/index.ts
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
// Use JSR/Deno-compatible imports instead of npm
import { createClient } from 'jsr:@supabase/supabase-js@2.49.8';
serve(async (req) => {
const supabase = createClient(
Deno.env.get('SUPABASE_URL')!,
Deno.env.get('SUPABASE_ANON_KEY')!
);
return new Response('Function works!');
});Check the Supabase Edge Functions documentation for compatible packages. Run deno check index.ts locally to catch type errors before deploying.
Some users have reported deploy issues with specific CLI versions. Update to the latest version:
# Update Supabase CLI
npm install -g supabase@latest
# Or for a specific version that's known to work
npm install -g supabase@1.61.0
# Deploy with debug output to see what's happening
supabase functions deploy <function-name> --debugThe --debug flag will show detailed logs of the deployment process, helping you identify where the deploy is failing.
Advanced notes
Edge Functions are built on Deno, not Node.js. This means npm modules may not work directlyβyou must use JSR (JavaScript Registry) or Deno-compatible imports. Import paths should use full URLs or JSR imports instead of npm package names.
Known issues: Some users have reported functions work with "supabase functions serve" locally but return 404 when deployed. This is often caused by npm package compatibility issues. Using deno check locally before deploying can catch these errors early.
Branching: If using Supabase branching, ensure you're calling the function with the correct URL for the branch environment and using the corresponding anon key.
Frequently asked questions
- What does "EF002" mean?
- Supabase Edge Functions are serverless functions built on Deno that run in response to HTTP requests. When you invoke a function using its URL endpoint, Supabase's routing system must locate and execute the corresponding function code. The "Function not found" error means the routing system couldn't find a deployed function matching your request URL.
- How do I fix "EF002"?
- This error occurs when a request is sent to a Supabase Edge Function that doesn't exist, hasn't been deployed, or the URL is incorrect. It typically returns a 404 HTTP response with error code EF002.
- What causes "EF002"?
- Function name in the URL doesn't match the folder name in supabase/functions/ directory Function hasn't been deployed yet or deployment failed silently Function was deployed but deployment used wrong function name or path
- Is the "EF002" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- πSupabase Official Documentation
- πSupabase Docs: Edge Functions Troubleshooting(Official Docs)
- πSupabase Docs: Deploy Edge Functions(Official Docs)
- π
- π
- π