DNS lookup failed err=202 res=0x0

pablogurjao
Posts: 7
Joined: Thu Jun 08, 2017 6:34 pm

DNS lookup failed err=202 res=0x0

Postby pablogurjao » Thu Jun 08, 2017 7:34 pm

good afternoon,
I'm working with esp 32 and I'm try to reproduce the http_request _example form esp-idf and I'm with some trouble in this peace of code:

Code: Select all

#define WEB_SERVER "example.com"
.
.
.
struct addrinfo *res;	
struct addrinfo hints = {
          .ai_family = AF_INET,
	   .ai_socktype = SOCK_STREAM,
};	
int result = getaddrinfo(WEB_SERVER , "80", &hints, &res);
if((result != 0) || (res == NULL))
{
	ESP_LOGE(log_string, "DNS lookup failed err=%d res=%p", result, res);
}
The condition "if" is called and this error apear:

DNS lookup failed err=202 res=0x0

Someone knows how to solve this problem?

Sprite
Espressif staff
Espressif staff
Posts: 10599
Joined: Thu Nov 26, 2015 4:08 am

Re: DNS lookup failed err=202 res=0x0

Postby Sprite » Fri Jun 09, 2017 7:23 am

202 is EAI_FAIL, which is a general permanent failure. Are you sure WiFi is up and running? If so, can you maybe do a packet dump using Wireshark or something?

pablogurjao
Posts: 7
Joined: Thu Jun 08, 2017 6:34 pm

Re: DNS lookup failed err=202 res=0x0

Postby pablogurjao » Fri Jun 09, 2017 2:26 pm

My function request was been called before the end of my function wifi_connect, when I put a function to wait the end of wifi_connect, it worked.
Thanks!

Ritesh
Posts: 1395
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: DNS lookup failed err=202 res=0x0

Postby Ritesh » Sat Apr 13, 2019 4:33 am

202 is EAI_FAIL, which is a general permanent failure. Are you sure WiFi is up and running? If so, can you maybe do a packet dump using Wireshark or something?
Hi,

We are working on ESP32 IDF 3.1 Stable release and we are using MQTT protocol as per requirement with external network access.

We have created one hotspot into mobile and doing stress testing to connect and disconnect with mobile hotspot and MQTT server which we have prepared as per requirement.

So, sometimes, we have faced issue of Getaddresinfo failed with error as 202 and also tried to capture wifi traces in which we have observed that DNS query gets failed to resolve.

We have also checked with MQTT server and also dumped request but didn't find much details.

So, Would you please help me like what can be possible reason for this issue and how it can be resolved?

Let me know if you need any more details regarding that.
Regards,
Ritesh Prajapati

rljonesau
Posts: 1
Joined: Wed Jun 25, 2025 3:26 am

Re: DNS lookup failed err=202 res=0x0

Postby rljonesau » Wed Jun 25, 2025 3:35 am

202 is EAI_FAIL, which is a general permanent failure. Are you sure WiFi is up and running? If so, can you maybe do a packet dump using Wireshark or something?
Sorry to dredge up such an old post, but the info you provided is still 100% useful 5+ years later.
I was battling this same issue trying to open via mqtt_connect and always failing on the DNS lookup with 202.

My problem was my bad usage of "STA_CONNECTED" alone, whereas the fix was to instead check for "GOT_IP".

So refactored my "isSTAconnected" function to include the captured GOT_IP status flag (from wifi event handler) and bingo, works properly.

THANK YOU!!!

Ritesh
Posts: 1395
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: DNS lookup failed err=202 res=0x0

Postby Ritesh » Wed Jul 02, 2025 4:40 am

202 is EAI_FAIL, which is a general permanent failure. Are you sure WiFi is up and running? If so, can you maybe do a packet dump using Wireshark or something?
Sorry to dredge up such an old post, but the info you provided is still 100% useful 5+ years later.
I was battling this same issue trying to open via mqtt_connect and always failing on the DNS lookup with 202.

My problem was my bad usage of "STA_CONNECTED" alone, whereas the fix was to instead check for "GOT_IP".

So refactored my "isSTAconnected" function to include the captured GOT_IP status flag (from wifi event handler) and bingo, works properly.

THANK YOU!!!
Thanks for sharing your feedback with details like your issue has been fixed and working fine.

So, would you please share some more information with code example snippet like what kind of error you are getting and how you have fixed it with some examples?

It would be really great to see those kinds of details so that would be helpful to others who are still facing same kind of issues into latest ESP IDF.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: PetalBot, Qwantbot and 5 guests