How to Fix cURL Error 7 Failed to Connect on CentOS

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.

Solution

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.


Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.