Errors / checked October 9, 2026

curl: (22) The requested URL returned error: 404

The error

Output of curl -f (--fail) when the server answers with an HTTP status of 400 or above; the number at the end is that status (401, 403, 404, 500, 503...). Typical in cron jobs and CI scripts that call a URL with curl -fsS. Reproduced 2026-11-13 with curl 8.5.0 on Ubuntu 24.04. curl 8.7.1 on macOS printed the same message with exit code 56 instead of 22 over HTTP/2, and 22 with --http1.1.

Quick fix

  1. Read the status at the end of the line. 401 or 403: the token or key is missing, expired or not sent (check the header in your script, and that cron sees the variable). 404: the URL or path is wrong, or the route was removed. 500 and up: the server failed; its logs say why.
  2. See what the server said: --fail hides the response body. Run the same command with --fail-with-body (curl 7.76.0 or later) to keep the exit code and print the body.
  3. For errors that come and go, add --retry 3. curl retries HTTP 408, 429, 500, 502, 503, 504, 522 and 524 responses, waiting 1 second and doubling the wait each time.

Why this happens

By default curl does not treat an HTTP error status as a failure: a 500 still exits 0. --fail changes that: curl returns exit code 22 for any response of 400 or above and prints no body, so a script or cron job can tell the call failed.

Source: curl man page: --fail and exit code 22

Other solutions

  • Keep -f in scheduled calls. Without it a cron job that gets a 500 every night exits 0 and looks fine.
  • If a script checks for exit code 22 specifically, also accept 56, or force --http1.1, for older macOS curl versions.
  • A hosted scheduler records the status and response of every call for you. RunLater treats any status outside 2xx as a failure, retries it up to 10 times with exponential backoff, keeps each response 7 to 90 days by plan, and emails you when a run fails after its retries.

Check a schedule before you deploy it: the cron expression explainer shows the next 10 run times.

Frequently asked questions

What does curl exit code 22 mean?

The server returned an HTTP status of 400 or above and --fail was used. curl only returns 22 with --fail; without it, an error status exits 0.

How do I see the response body with --fail?

Use --fail-with-body instead of --fail. It returns the same exit code 22 and still writes the body, so you can see the error message the server sent.

Why did I get exit code 56 for a 404?

curl 8.7.1 on macOS returned 56 instead of 22 for an HTTP error with --fail over HTTP/2 in our test, with the same "The requested URL returned error" message. With --http1.1 it returned 22.

Have the URL called on schedule, with retries

RunLater calls your URL on a cron schedule or at an exact time, in your timezone, retries failed calls with backoff and logs each response, so a timeout or a 5xx shows up in a log instead of disappearing.

Start a 14-day trialStarter is $15/month for 250 scheduled requests and 25,000 runs. Cancel before day 14 and you pay nothing.

Related errors