How to Fix cURL Error 7 Failed to Connect on CentOS

Published on Apr 23, 2021

Sometimes we face “cURL error 7: Failed to connect to permission denied” this type of error due to our server permission. Most of the time we face if SELinux is enabled on our server. The curl request is blocked by SELinux.


Login to your server using SSH with root permission. Then just run this command:

setsebool -P httpd_can_network_connect on

After that we have to restart our web server:

# apache server
sudo systemctl restart httpd

# nginx server
sudo systemctl restart nginx
That’s all. Thanks for reading. ?

Comments (0)