Sitemap

Member-only story

Laravel HTTP Client Retry: Only Retry Failures That Matter

4 min readOct 10, 2026

--

Press enter or click to view image in full size

The Laravel HTTP client retry feature is easy to switch on and easy to misuse. Http::retry(3, 100) retries on almost any failure, including a 404 that will never succeed and a 422 validation error that will fail identically every time. Each wasted attempt adds latency and load to someone else's API. retry() has two lesser-known arguments that fix this: a callback that decides whether a failure is worth retrying, and a throw flag that controls what you get back when every attempt fails.

The default: retry everything

use Illuminate\Support\Facades\Http;

$response = Http::retry(3, 100)->post('https://api.example.com/orders', $payload);

The first argument is the maximum number of attempts and the second is the wait between them in milliseconds. If the request fails with a client or server error, Laravel tries again. That is fine for a flaky network and wrong for a request that is simply invalid.

Decide what to retry with the third argument

Per the Laravel documentation, the third argument is a callable that determines whether the retries should actually be attempted. It receives the exception and the pending request. Return true to retry and false to stop.

--

--

Dev Talk
Dev Talk

Written by Dev Talk

Software Engineer with extensive experience in full-stack web development, specializing in Laravel, JavaScript, and scalable backend systems.