Score:1

Why does Ubuntu give "could not resolve host for external urls" called from code?

ng flag

I have tow servers running Ubuntu, and I have hosted sites on both of them.

Some are Laravel and some are Python sites.

Suddenly, on both servers, and despite of code being unchanged for a while, I get random errors like these:

Could not resolve host: api.x.ai
Could not resolve host: api.y.com
Could not resolve host: api.z.sa
Max retries exceeded with url: api.g.com

System details: lsb_release -a:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

They appear very very often but not on 100% of visitors actions. There is some random thing happening

So what could be wrong?

Please assist because I followed some instructions to disable ipv6 and clear DNS cache and rebooting the servers and I got no results.

Thanks!

Abeer Sul avatar
ng flag
@guiverc added, thanks!
Abeer Sul avatar
ng flag
@guiverc I made a typo while writing the tags, I wanted to tag ubunto but it's not allowed, I changed them
Raffa avatar
jp flag
I guess `Max retries exceeded with url:...` is comming from a Python script using the `requests` module ... If so, then you might want to rephrase your question accordingly as it should then be more Python focused than it is Ubuntu focused.
Abeer Sul avatar
ng flag
@Raffa code is unchanged for months, and now the errors are showing in both websites, I think something weird from the server is causing this but I can't find it
Score:0
ng flag

The solution I found was to use these when calling the external APIs:

curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

This worked successfully. And for the last error, seems like the service provider blocked my server by mistake and I contacted support and it was solved.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.