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

MoFish's avatar

Get request on a localhost api

Hi,

I have very simple api in my localhost and am using php artisan to serve for now.

When i try to call this from a controller, i am receiving an error message.

Operation timed out after 30002 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
$response = Http::get('http://127.0.0.1:8000/api/film/');
$data = json_decode($response->body(), true);
dd($data);

I suspect this is due to me running the website using php artisan and referencing a local ip address?

Is there an easy solution to this problem? Any help/guidance much appriciated.

Thanks,

MoFish

0 likes
1 reply
MoFish's avatar
MoFish
OP
Best Answer
Level 1

Ahh, i found a dirty solution for the short term. Not sure if there is a better way?

Serve the website again on a different port number e.g.

php artisan serve --port 3001

I suspect trying to perform two get operations (page/api) at the same time was causing issues.

Please or to participate in this conversation.