I upgraded php version to 8.3.6, laravel to v11 and new apache running in local machine, i though the problem was related with apache but finally I found this:
file_get_contents('http://localhost:8000/storage/5cc9629864cd3.png'); // Failed to open stream: HTTP request failed!
file_get_contents('storage/5cc9629864cd3.png'); // it works!
Then I run another php artisan serve on port 8001 and i connect from 8000 server to 8001 and it works:
file_get_contents('http://localhost:8001/storage/5cc9629864cd3.png'); // it works!
Artisan serve is a shortcut for running the built-in PHP server, which is meant for local development only. Port 8000 is either served by the built-in server or Apache. It can't be both. It looks like you're using the built-in server.
Your request fails because the built-in server runs in one single-threaded process. That means every request has to wait for the previous request to finish before a new one can be handled.
If you make another HTTP request to your app during a request lifecycle (which you should never need to do), then that request will wait for the current request to finish. The current request is waiting for a response to the new request and you have a deadlock. The request will fail and you get an error.
But there's no need to retrieve your image over HTTP when you already have it on your server. You should instead do something like:
So apart from the fact that you are trying to read some random local file via http instead of using the file system, why would you hard code local server name into your code. When you take your code into production, you never want hard coded URLs littering your code.