I have setup two apps in my WAMP environment. Performance of both the sites is OK. They return data in less than a second. The problem is that when I curl one site from another the curl takes around 20 seconds to respond. I have done profiling. Actually CURL request is taking all the time.
This should not be the case as both sites are setup on my machine and I am accessing using localhost/127.0.0.1 . Is it some sort of DNS resolve issue?
I had the same problem and finally discover that it was coming from two facts :
http://myproject.local/
because I put a line 127.0.0.1 myproject.local
in /etc/hosts
It is because the .local
tld is reserved for Bonjour service, and this since Mac OS X Lion (10.7).
Changing the tld for something else fixed the problem.
Yes, is a DNS lookup problem.
On Windows 7 x64 i managed to overcome this issue
(curl call between applications on different ports in localhost) by editing the host file ( C:\Windows\System32\drivers\etc ).
Un-comment on the line that says: 127.0.0.1 localhost , reboot and you're done.
I solved this problem by setting up different virtual hosts such as sitea.dev and siteb.dev If you use the same host for both sites on your localhost Windows machine, then you get a long delay (the same as if there is a Fatal PHP error). It's not a problem with Curl since file_get_contents(url) gave me the same issue.
If you are using *.local TLD, you can solve this and enjoy fast loading times by adding both, IPv4 and IPv6 entries in the hosts file
127.0.0.1 test.local
::1 test.local
Best
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With