DNS Issue

I need help here is sample code

<?php
// Initialize cURL session
$ch = curl_init();

// Set cURL options
$url = 'https://aviationweather.gov/api/data/metar?ids=KMCI';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Accept: */*'
]);

// Execute cURL session and capture the response
$response = curl_exec($ch);

// Check for errors
if(curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

// Close cURL session
curl_close($ch);

// Output the response
echo $response;
 
?>

Once I run it on the website, I get the error: ‘Could not resolve host: aviationweather.gov’. But if I run the same code on localhost, I successfully obtain the data. I suspect it’s a DNS issue. How can I fix it?

This is mostly a server issue that is not something you can fix. Admin has to report this to the actual server operators to get this fixed, so you probably have to wait.

3 Likes

Most likely that API endpoint is blocked by the server, but Admin will be able to take a closer look and raise a question upstream if needed.

2 Likes

I’m having the same issue with catalog.archives.gov. How do I get InfinityFree to investigate?

I’m sorry for the delay.

I have checked the issue and there indeed seems to be a DNS problem on the free hosting servers preventing connections to these .gov domains.

I have asked iFastNet to investigate the issue.

3 Likes

I’m sorry again for the delay. The issue should now be fixed!

4 Likes

Yes! Thank you very much!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.