Skip to content

DNS lookup error -5 #4949

Closed
Closed
@jsdevel

Description

@jsdevel

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP-12 (NodeMCU 1.0)
  • Core Version: bde83e8
  • Development Env: Arduino IDE
  • Operating System: Fedora 27

Settings in IDE

  • Module: NodeMCU (ESP-12E)
  • Flash Mode: Not sure
  • Flash Size: 4MB/1MB
  • lwip Variant: v2 Lower Memory
  • Reset Method: Not sure
  • Flash Frequency: Not sure
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 921600

Problem Description

DNS doesn't consistently resolve when the ESP is connected to my NETGEAR R6300 router. I have no idea why. I've tried wiping flash a few times, all to no avail. I feel like DNS used to resolve hostnames on this network just fine, but now it's not.

I have 3 different Access Points that I test my sketch with:

  • NETGEAR R6300 (SSID NETGEAR61)
  • NETGEAR R7000 (SSID NETGEAR-SP)
  • Nexus 6p Hotspot (SSID AndroidAP)

DNS works on all but the first.

Successful Sketch Run

Connecting.......                                                                    
Connected, IP address: 192.168.5.14                                                  
DNS #1, #2 IP: 192.168.5.1, 0.0.0.0                                                  
yahoo.com IP: 98.137.246.7

Un-successful Sketch Run

Connecting.                                                                          
Connected, IP address: 192.168.4.13                                                  
DNS #1, #2 IP: 192.168.4.1, 0.0.0.0                                                  
DNS lookup failed.  Rebooting... 

MCVE Sketch

#include <ESP8266WiFi.h>

void setup()
{
  Serial.begin(115200);
  Serial.println();
  connectToWifi("NETGEAR61", "XXXXXXXX");
  // connectToWifi("AndroidAP", "XXXXXXXX");
  // connectToWifi("NETGEAR-SP", "XXXXXXXX");
  printDNSServers();
  printIPAddressOfHost("yahoo.com");
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(500);                       // wait for a second
}

void connectToWifi(const char* ssid, const char* password) {
  WiFi.begin(ssid, password);

  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());
}

void printDNSServers() {
  Serial.print("DNS #1, #2 IP: ");
  WiFi.dnsIP().printTo(Serial);
  Serial.print(", ");
  WiFi.dnsIP(1).printTo(Serial);
  Serial.println();
}

void printIPAddressOfHost(const char* host) {
  IPAddress resolvedIP;
  if (!WiFi.hostByName(host, resolvedIP)) {
    Serial.println("DNS lookup failed.  Rebooting...");
    Serial.flush();
    ESP.reset();
  }
  Serial.print(host);
  Serial.print(" IP: ");
  Serial.println(resolvedIP);
}

Debug Messages

connected with NETGEAR61, channel 11
dhcp client start...
wifi evt: 0
.ip:192.168.4.13,mask:255.255.255.0,gw:192.168.4.1
wifi evt: 3
.
Connected, IP address: 192.168.4.13
DNS #1, #2 IP: 192.168.4.1, 0.0.0.0
[hostByName] request IP for: yahoo.com
[hostByName] Host: yahoo.com lookup error: -5!
DNS lookup failed.  Rebooting...

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions