Sanjay Gupta
Sanjay Gupta

Reputation: 23

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known

This is my code bellow:

$ip_data = json_decode(file_get_contents("http://geoplugin.net/json.gp?ip=119.82.67.243"));
echo "<pre>"; 
print_r($ip_data);
die;

When I run this 2 different on 1 system its ok but on second system its giving error

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known

I have already checked allow_url_fopen=On is on both system so please suggest some other soln...thanks

Upvotes: 2

Views: 8240

Answers (1)

PawelN
PawelN

Reputation: 338

  • try to flush your DNS cache and try again :) if it doesn't help:
  • try to do this that way: fopen('your url','r')... but i think this won't change anything

If there is a problem with dns on second environment you can do this:

<?php
echo gethostbyname("ONLY_ HOST_HERE_WITHOUT_HTTP_PROTOCOL"); // debug
var_export (dns_get_record ( "ONLY_HOST_HERE_WITHOUT_HTTP_PROTOCOL") ); ?>

and you can change your dns servers:

$dns=array("194.204.159.1","194.204.152.34","8.8.8.8","8.8.4.4"); // or you can pass DNS from your first machine :)
var_export (dns_get_record ( "ONLY_ HOST_HERE_WITHOUT_HTTP_PROTOCOL" ,  DNS_ALL , $dns ));

Upvotes: 1

Related Questions