0

I'm running a Virtual Private Server to host some websites. I have a PHP script that tries to fetch resources from the server, essentially using a curl command to the server (http://example.com/files/resource.txt) which fails. I've tried simulating the command from the server terminal which fails with a timeout and even when I ping the server (example.com) I get 100% packet loss.

However, if I try to curl the same file from elsewhere, it succeeded. Additionally, if I try to curl any other website from the server that succeeds.

So my suspicion is that the server doesn't know where to go to get to example.com. I have found mentions of using the command line parameters for curl but that won't solve the problem with curl'ing from PHP.

Any ideas?

Server: Debian 7.6

DNS: bind9

Other: apache2, nginx, exim4, dovecot, mysql, vsftpd, cron

Tim Lewis
  • 1
  • 4

2 Answers2

0

Maybe your domain is new enough that DNS propagation delay is an issue?

Try cat /etc/resolv.conf to check which nameserver it's using. Alternatively, if you have root access, you can always add the FQDN to /etc/hosts if the server's IP is static.

André Fernandes
  • 969
  • 1
  • 10
  • 25
  • If it were dns, the error message would indicate it can't resolve not give a timeout. – AD7six Oct 31 '14 at 10:30
  • Right. I would suspect a firewall blockade then... – André Fernandes Oct 31 '14 at 16:20
  • Thanks for the help guys. The comments around the DNS make, sense. I have a slightly complex DNS setup which is why my suspicion started there. I could curl/ping from outside. It turned out it was a firewall issue. My provider prevents traffic returning on the same port it entered the firewall. So the traffic would go out to the firewall, then realise that it needed to be directed to the ip it was coming from, and then the fw would squash the traffic. I added an entry to the hosts file and that solved the issue. Thanks for the help. – Tim Lewis Nov 03 '14 at 11:09
0

So it turned out that my host disabled loopback queries on all servers.

So assuming my site is running on example.com: My server made a request to example.com, the when a request would leave my server, and reach the host's infrastructure (maybe a firewall) and that would resolve back to the server the request came from (my server), and it would silently kill the request.

The solution is to modify the hosts file on the server to point example.com to 127.0.0.1

Tim Lewis
  • 1
  • 4