In my case (running on Centos 8), this error was caused by SElinux preventing apache
(the login running the web server) from using the connect(2)
system call.
Try running in permissive mode — if that works, change your SELinux configuration as appropriate.