curl_getinfo returns HTTP 200 status code with non-existing sites curl_getinfo returns HTTP 200 status code with non-existing sites curl curl

curl_getinfo returns HTTP 200 status code with non-existing sites


sorry for abusing the answer field for what should probably be a comment but I can't really think of a way to present this info properly otherwise. I honestly don't know yet how to whip them comments into any properly displayed and formatted shape. :-|

Anyway, since your code should be working fine but for you it always retuns "everything OK" while you check for a HTTP response, it could be that your ISP is doing DNS-highjacking, which basically is returning fake ip-address data, redirecting you to their own server, usually for monetary gains under the guise of userfriendlyness. (ISP-page that shows "this page doesn't exist" combined with ads or the offer of services such as domain registration, etc..)

an easy way to test is just to ask for DNS data with an application like dig. A query to a properly functioning DNS server for a non-existing domain should return NXDOMAIN as its status:

so when we check for a totally fake domain notexisting.fake with the following command:dig A notexisting.fake., this is what it generally should give:

harald@Midians_Gate:~$ dig A notexisting.fake.; <<>> DiG 9.7.3 <<>> A notexisting.fake.;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 28725;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0;; QUESTION SECTION:;notexisting.fake.              IN      A;; AUTHORITY SECTION:.                       1780    IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2012061700 1800 900 604800 86400;; Query time: 24 msec;; SERVER: 8.8.8.8#53(8.8.8.8);; WHEN: Sun Jun 17 18:05:10 2012;; MSG SIZE  rcvd: 109

as you can see,asking for this nonexisting domain notexisting.fake. returns us

;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 28725

Whereas when we query for google.com, with dig A google.com.

harald@Midians_Gate:~$ dig A google.com.; <<>> DiG 9.7.3 <<>> A google.com.;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13223;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0;; QUESTION SECTION:;google.com.                    IN      A;; ANSWER SECTION:google.com.             300     IN      A       74.125.132.138google.com.             300     IN      A       74.125.132.139google.com.             300     IN      A       74.125.132.101google.com.             300     IN      A       74.125.132.113google.com.             300     IN      A       74.125.132.100google.com.             300     IN      A       74.125.132.102;; Query time: 29 msec;; SERVER: 8.8.8.8#53(8.8.8.8);; WHEN: Sun Jun 17 18:05:20 2012;; MSG SIZE  rcvd: 124

our query returns us the proper NOERROR

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13223;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

and returns us the ip address found for the A record

;; ANSWER SECTION:google.com.             300     IN      A       74.125.132.138google.com.             300     IN      A       74.125.132.139google.com.             300     IN      A       74.125.132.101google.com.             300     IN      A       74.125.132.113google.com.             300     IN      A       74.125.132.100google.com.             300     IN      A       74.125.132.102

So if your query for the fake domain returns an ip address then you know the problem is with your DNS and your isp no doubt redirects every non-existing request to a server of their own, messing with your 'is my site up strategy' since you'll get a 200 OK status but it'll effectively be from an imposter.

If this is the case then you can only:

  • change your DNS server: use Google Public DNS (8.8.8.8 and 8.8.4.4) or opendns (208.67.222.222 and 208.67.220.220)
  • plead/complain with your isp for them to change this policy or to supply you with your own non-redirecting DNS server
  • run your own private DNS server for your personal lookups if allowed on your network.