Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AtomCoder's avatar

HTTP Client - Incorrect Status Code Response

Hi Guys,

I'm having a niggly issue with the Laravel HTTP Client. Im making simple GET requests to test but it seem to be returning incorrect status codes.

For example if I send a request to : Http::get('https://www.google.com') I get a response of 200

However, if I make a request to : Http::get('https://www.google.com/jibberish') I also get a response of 200.

This is not the expected response. Any ideas why this might be?

I've used this site to send the same HTTP requests and I get the expected bahaviour 200 & 404 status codes

Test HTTP Request Site: https://check-host.net/

0 likes
7 replies
aruszala's avatar

@AtomCoder this is what I get:

use Illuminate\Support\Facades\Http;

// ...

$response = Http::get('https://www.google.com')->status();
dd($response); // 200

// ...

use Illuminate\Support\Facades\Http;

// ...

$response = Http::get('https://www.google.com/jibberish')->status();
dd($response); // 404

// ...

Try to put this in your routes file and test the result in the web browser. What do you get?

Also, provide more information on how you're getting your results so we could replicate the same issue.

Are you running it inside of a test?

Are you using Http::fake() to fake the response?

aruszala's avatar

@atomcoder if you're using caching, changing the URL after the response has already been cached could be the reason.

aruszala's avatar

@atomcoder so if it works in the routes file, how/where are you calling it when you get the wrong result?

AtomCoder's avatar

@aruszala I'm calling it from a scheduled command.

Also, I have a redirect on a domain (as a test), but when I make a get request using HTTP::get, it returns status 200.

In this instance I'm expecting a 302 Found status.

I'm also using the helper provided by laravel $response->found()

In fact, none of the helpers are working, for 500 internal errors, 422 Unprocessable Entity etc.......

Really weird situation.

Please or to participate in this conversation.