As a guess, you are using PHP webserver (php artisan serve) ?
It only handles one request at a time, so you cannot start another request from inside a request.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This works fine: http://127.0.0.1:8000/api/all
//api.php:
Route::get('all', function () {
return 'everybody may access this api route';
});
But when I call the same route from within another route, I never get a response, and it keeps spinning...
What am I doing wrong?
api.php:
Route::get('/test', 'AuthController@test');
//AuthController.php:
...
use GuzzleHttp\Client;
class AuthController extends Controller
{
public function test(Request $request)
{
$client = new Client([
'timeout' => 8.0,
]);
//return 'gets here ok1';
$response = $client->get('http://127.0.0.1:8000/api/all');
//return 'does NOT get here';
//500 internal error, the timeout I set at above line, otherwise it keeps spinning
return $response->getBody();
}
}
So http://127.0.0.1:8000/api/test never gets back...
As a guess, you are using PHP webserver (php artisan serve) ?
It only handles one request at a time, so you cannot start another request from inside a request.
Please or to participate in this conversation.