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

pratikzajam's avatar

Not able to get response from get api in Laravel

I am trying to fetch data and integrate into application from get api in laravel but getting this error

"cURL error 28: Operation timed out after 30011 milliseconds with 0 bytes received".

I am able to get response from same api in postman. also i tried third party api's with same laravel code and i am able to fetch data with those apis.

My laravel code

<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Http;
use Illuminate\Http\Request;

class ApiController extends Controller
{
    public function index()
    {
        $bookingData = Http::get("http://127.0.0.1:8000/api/viewbookings");

       return json_decode($bookingData);
    }
}

my Api response i am getting through postman

{
    "message": "data sucessfully fetched",
    "data": [
        {
            "name": "Pratik Zajam",
            "booking_date": "2023-09-23",
            "timeslot": "10-11"
        },
        {
            "name": "Pratik Zajam",
            "booking_date": "2023-09-23",
            "timeslot": "11-12"
        },
        {
            "name": "Pratik Zajam",
            "booking_date": "2023-09-24",
            "timeslot": "11-12"
        }
    ]
}

I tried to test my laravel code with third party apis and it did worked. but not able to data through my own api.

0 likes
2 replies
s4muel's avatar
s4muel
Best Answer
Level 50

this unfortunately is not possible (i mean, at least in this simple out-of-the-box form), because the php built-in server is single-threaded. but there is a chance, you have two options:

either start two servers and connect from one to another (different port),

or try this suggestion from internet, start the server with multiple workers: PHP_CLI_SERVER_WORKERS=10 php artisan serve

Please or to participate in this conversation.