Solving slow curl and wget calls in CentOS

By | May 31, 2016

I recently ran into an issue with very slow curl and wget calls. After diagnosing for a while I realized that it had something to do with resolving DNS. My nameserver entries were set as 8.8.8.8 and 8.8.4.4 so I didn’t think the name servers were the problem.

After a lot of trial an error these are the steps I took to fix this-

In /etc/resolv.conf –
options single-request-reopen
nameserver 8.8.8.8
nameserver 8.8.4.4
The single line – options single-request-reopen seems to do most of the heavy lifting. Now after you do that run
sudo service network restart
Check the /etc/resolv.conf file and make sure that the changes are still there. If they are not, then you will need to do this:
In /etc/sysconfig/network-scripts/ifcfg-eth0
#DNS1=8.8.8.8
#DNS2=8.8.4.4
PEERDNS=no
sudo service network restart
Then make the above changes again.
From what I can tell, there is some sort of conflict between ipv4 and ipv6. Even though the above changes will fix the problem, you might also want to disable ipv6 until the bugs are sorted out.
In /etc/sysctl.conf –
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Then run
sudo sysctl -p
So basically if you’re running into any problems with your server connecting to other servers hopefully this will help. I specifically ran into this issue with WordPress and the Jetpack plugin as well as WordPress’s dashboard.
I’m using CentOS 7 however I believe this issue is in many other Linux distro’s.

2 thoughts on “Solving slow curl and wget calls in CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *