Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

On our site we run a few different scripts for various sites (uploading to amazon s3, data from chartbeat, script to count twitter followers) and all of them just stop working from time to time. They work most days, but then some days (like today) they all just stop working.

This simple script to get follower count into PHP

$url = "http://twitter.com/users/show/username";
$response = file_get_contents ( $url );
$t_profile = new SimpleXMLElement ( $response );
$count = $t_profile->followers_count;

Just sits there for a couple minutes, then finally spits out an error that says "Couldn't resolve host". Any script we use for an external site gives us this error. I'm not really sure where to check what's blocking these connections all of a sudden, and why it seems to work most times, then doesn't for a day or so, then works again.

Any tips?

Update: Contents of resolv.conf

search 147.225.210.rdns.ubiquityservers.com
nameserver 72.37.224.5
nameserver 72.37.224.6
share|improve this question

1 Answer 1

up vote 4 down vote accepted

The symptoms you describe are a classic case of your DNS servers not responding. When none of the DNS servers are available, then hostnames cannot be resolved to IP addresses, and you can't reasonably connect to anywhere (at least by name).

It appears that you're using DNS servers given to you by the datacenter where your server resides. The reliability of such servers is often questionable.

Try using known-good servers such as Google Public DNS instead.

nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
nameserver 8.8.8.8
nameserver 8.8.4.4
share|improve this answer
    
Thank you. Seems to have fixed the issue right away. –  scatteredbomb Jun 28 '13 at 4:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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