Curl request wont resolve to localhost

Your comment: "it listens on 192.168.2.1 and then a public IP. loopback device is 127.0.0.1". So, Apache isn't listening on 127.0.0.1? If that's the case, that is your problem. Configure Apache to listen to all interfaces, or at least add the loopback interface to what Apache is listening on.

Next issue: "If I make a curl request to sub.domain.com on that machine it will sit there in an infinite loop until it times out after a few minutes." What do you get when you ping sub.domain.com? This issue feels like a name resolution problem on that machine, as you're able to connect successfully from another machine.


You likely need to specify the host headers using curl or else Apache doesn't know what page to display - depending on how you are set up localhost will probably show an apache default page, while your virtual host (sub.domain.com) will show the page you expect.

Try using:

curl -H "Host:sub.domain.com" 127.0.0.1

Do ping sub.domain.com from another machine and record ip address in responses (xxx.yyy.zzz.www). Then from apache machine use:

curl -H "Host:sub.domain.com" xxx.yyy.zzz.www