I can use lynx to access a website from the server fine. When I try to access the same website with a php curl instruction I get http_code=>0
from curl_getinfo($ch);
The same php code on another redhat server in the same data centre works fine. I have admin access to the server.
I have tried php 7.4 and php 8.0.
curl
is enabled when I call phpinfo();
I am unsure how to debug this error!
It is RHEL 8.8
This is the output from curl_getinfo($ch);
Array ( [url] =>
https://..... [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.055895 [namelookup_time] => 0.105978 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 [http_version] => 0 [protocol] => 0
[ssl_verifyresult] => 0 [scheme] => [appconnect_time_us] => 0
[connect_time_us] => 0 [namelookup_time_us] => 105978
[pretransfer_time_us] => 0 [redirect_time_us] => 0 [starttransfer_time_us] => 0 [total_time_us] => 55895 )
setsebool -P httpd_can_network_connect on
This worked. The full answer is here: CURL not working from web browser on Red Hat, Apache, PHP, AWS