How to Fix cURL Error 7 Failed to Connect on CentOS

Published on April 23, 2021 18 sec read

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. 🙂

Monthly Newsletter

One email a month, packed with the latest tutorials, delivered straight to your inbox.
We'll never send any spam or promotional emails.
Author

Hey, I'm Md Obydullah. I build open-source projects and write on Laravel, Linux server, modern JavaScript and more on web development.

Follow