After installing Centos 7, I noticed that DNS lookups for addresses saved in /etc/hosts take long time, here is example:

time curl -X get http://localhost

real    0m0.159s
user    0m0.004s
sys     0m0.005s


time curl -X get

real    0m0.005s
user    0m0.001s
sys     0m0.003s

It takes ~ 0.15 secs to resolve "localhost" by each request.

I make the same tests on another server in the same network with Centos 6.5 but "localhost" is as fast as ""

  • Compare /etc/nsswitch.conf on the two servers.
    – jordanm
    May 2, 2015 at 19:55
  • @jordanm i did replaced this file from the other server to this one, but no use.
    – Mido
    May 2, 2015 at 20:13

1 Answer 1


It's Red Hat Bug 1130239 - Difference in curl performance between RHEL6 and RHEL7:

The libcurl library used an unnecessarily long blocking delay for actions with no active file descriptors, even for short operations.  This meant that some actions, such as resolving a host name using /etc/hosts, took an artificially long time to complete.  The blocking code in libcurl has now been modified so that the initial delay is short, and gradually increases until an event occurs.  Fast libcurl operations now complete more quickly.

Install new version curl from source:

git clone https://github.com/bagder/curl.git
cd curl
yum install libtool
make install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.