Skip to content
Docs

Troubleshooting Vercel Cron Jobs

Learn how to troubleshoot cron jobs that aren't being run or logged when using Vercel Cron Jobs.

Justin Vitale

Copy link to headingAbout cron jobs

Cron jobs are automated tasks that run at specified intervals. Vercel Cron Jobs specifically are designed to work within the Vercel ecosystem, and allow you to schedule automated tasks to run at specified intervals on Vercel.

Copy link to headingImportant Considerations

  • Cron jobs will still execute even for paths that don’t exist, but a 404 will be returned.
  • New deployments do not affect existing cron jobs.
  • The timeout duration of cron jobs are identical to that of Serverless and Edge functions. If you're hitting these limits, consider splitting your cron jobs into smaller batches.

Copy link to headingTroubleshooting Vercel Cron Jobs

Copy link to heading1. Check your plan limits

Ensure you're within the cron job limits for your plan. Refer to Usage & Pricing for Cron Jobs.

Copy link to heading2. Verify the cron job is being run on a Production deployment

Cron jobs only run on `Production` deployments. Make sure you're not trying to run them on a `Preview` deployment.

Copy link to heading3. Validate your CRON_SECRET environment variable

Ensure your CRON_SECRET environment variable does not contain any invalid, new line, or special characters that cannot be used in the authorization header.

Copy link to heading4. Validate your cron job expression

Double-check that your cron job expression matches your intended schedule. You can use our cron expression validator to ensure it's correct.

Copy link to heading5. Cron jobs and redirects

Cron jobs do not follow redirects. When a cron-triggered endpoint returns a 3xx redirect status code, the job completes without further requests. Redirect responses are treated as final for each invocation. For example, if your cron job is in /api/cron, you could visit the following endpoint in your browser: http://localhost:3000/api/cron. You should be aware that while your browser may follow redirects, cron job invocations in production will not follow redirects. If your project has the trailingSlash option enabled, you need to add missing trailing slashes (/) to your cron jobs. This should prevent the redirect and allow the cron jobs to function as expected.

There is currently no support for vercel dev, next dev, or other framework-native local development servers. The view logs button on the cron job overview can be used to verify the response of the invocations and gain further insights.

Copy link to heading6. Use force-dynamic to prevent caching

If you're not seeing logs for your cron job, it might be due to caching. To prevent this, add export const dynamic = 'force-dynamic'; to your cron job's route handler. This ensures the function runs every time, rather than serving a cached response. Refer to the Cron Jobs Quickstart guide for further examples.

Copy link to heading7. Check your Vercel WAF rules

If you're using custom WAF rules, they might inadvertently block your cron job, especially if it's making requests to external services. Review your WAF configuration to ensure it's not blocking your cron job.

Copy link to heading8. Confirm that your function names and routes are valid and up-to-date

Make sure the function name or route in your cron job configuration matches what's in your project's Deployment Summary. If you've changed the function name or route since setting up the cron job, update your cron job settings accordingly.

Copy link to heading9. Confirm that cron is registered during build process

Run vercel build --prod locally and verify the .vercel/output/config.json file to ensure the crons property exist to register Cron Jobs properly during Build Step.

"crons": [ { "path": "/api/example-cron", "schedule": "* * * * *"} } ] }