2
I work with a team to develop a web service and client, each of us, of course, working on our own machines. To keep things simple and more consistent, we use similar domains in the code and update /etc/hosts
to resolve those domains to localhost.
- works fine for my web browser; response times are snappy
- curl and wget take ~4 seconds to resolve DNS before successfully completing the request
I did find the --resolve
flag for curl which resolves the delay, but I could just as well use 127.0.0.1
and define the headers necessary to get the same effect.
with flag (and updated /etc/hosts
file)
# /etc/hosts
...
127.0.0.1 mp-api.example.local
command
curl -k -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total}\\n \
--resolve mp-api.example.local:8094:127.0.0.1 \
-H 'Host: mp-api.example.local:8094' \
'https://mp-api.example.local:8094/api/categories/tree.json'
with 127.0.0.1
curl -k -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total}\\n \
-H 'Host: mp-api.example.local:8094' \
'https://127.0.0.1:8094/api/categories/tree.json'
What are some of the reasons for the delay in DNS resolution for tools like curl
and wget
? And what are some effective ways of troubleshooting that delay?
Does a service need to be recycled to pick up changes?
/etc/nsswitch.conf
doesn't exist on my computer. I added it, supplied with the values you suggested, but I'm still getting a 4 sec delay on curl and wget requests. Browser requests do not experience the same delay. – David Vezzani – 2016-07-23T18:16:28.517strange it not exists. AFAIK nss is part of glib. Try strace curl ... What distro you use? – Mikhail Moskalev – 2016-07-23T19:04:21.733
I'm on Mac OS (El Capitan); I don't have
strace
in my path, so I can't run that command.I installed with
brew
. – David Vezzani – 2016-07-23T19:12:56.030Sorry. I implied it Linux based. I added tag and note to question. – Mikhail Moskalev – 2016-07-23T19:17:59.070