“CURL ERROR 7 Failed to connect to Permission denied” error is caused, when for any reason curl request is blocked by some firewall or similar thing.
you will face this issue when ever the curl request is not with standard ports.
for example if you do curl to some URL which is on port 1234, you will face this issue where as URL with port 80 will give you results easily.
Most commonly this error has been seen on CentOS and any other OS with ‘SElinux’.
you need to either disable or change ‘SElinux’ to permissive
nano /etc/selinux/config
locate following line
SELINUX=enforcing
Change this to
SELINUX=disabled
reboot is needed
Hi,
I have a curl (7) error and tried everything so far in order to solve it without success.
I’m running Centos and I was hoping that your post would be the answer to this issue but when I checked the selinux configuration file I saw that it was already set to disabled.
Is there anything else you would recommend in order to solve this??
Mike
Next thing you need to check is the iptables.
please try listing iptables, and see what is there.
iptables -L
for testing just clear/Flush the iptables
iptables -F
once you flused the iptables, try the curl request.
—
To my knowledge SELINUX and iptables are the reasons for CURL ERROR 7 on centOS,
Hope this will help you.
It didnot work out for me . please suggest something . I have a presence server 10.106.140.211 and i am trying to put resource-list in that server from 10.106.140.215 using command
curl –upload-file resource-list.xml -H “Host: 10.106.140.211” -H “Content-Type: application/resource-lists+xml” -H “Connection: keep-alive” –digest -u test-user:test-user http://10.106.140.211:8080/mobicents/resource-lists/users/test-user/rahul_rl
hello
will someone please tell me how to where is the selinux configuration file in cpanel ?
Better way is
setsebool -P httpd_can_network_connect on
You made my day too phpdreamer 🙂
You solve my problem.
Thanks man.
thanks this made my day
lovely you help me to fix major issues, was finding last 2 days
Thank you.
You made my day 🙂
hi, i am facing this issue (permission denied error with curl) while connecting to google GCM service.I have tried various options, nothing worked.
Thank you. This was really helpful.
This command:
setsebool -P httpd_can_network_connect on
fixed my issue.
thanks for the posting!
[…] 也可以参考这个网站http://www.akashif.co.uk/php/curl-error-7-failed-to-connect-to-permission-denied。 […]
How do I do this
setsebool -P httpd_can_network_connect on
on a shared hosting server
How do I do this — setsebool -P httpd_can_network_connect on— on a shared hosting server
“setsebool -P httpd_can_network_connect on” solved my issue. Thanks so much
[…] http://www.akashif.co.uk/php/curl-error-7-failed-to-connect-to-permission-denied […]
Thank you. Very Helpful
I have this problem in Raspberry pi 3b, running rasbian Stretsch. Non of the options above are posible here. Anny suggestions?
For me under CentOS 8 this was the syntax accepted:
sudo setsebool httpd_can_network_connect 1
Thanks, never would have found this without your post!
Thnx for alle the replies. The trick in CentOS 8 works for me. It takes a few hours to find it before I found this page. Thnx anyone!
absolute legend phpdreamer. I was racking my brain on this for a while.
Running that command on my CentOS 8 setup fixed the issue.
I had issues connecting to Google cloud datastore and i was getting CURL error 7. After running the command, the API works perfectly!
Thanks.
Thank you. Had this issue on aws RHEL 8 Instance and couldn’t figure it out on my own.
I am running windows 7 on my notebook. And I tried to download laravel installer using composer. But I found curl error 7 message return every time I run my code to download the laravel installer. What should to solve that problem? I’ll be waiting for your answer. May you happy and successful!