Go Down

Topic: ESP8266 hostByName fails with specific IPAddress (Read 256 times) previous topic - next topic


Nov 22, 2019, 09:21 pm Last Edit: Nov 22, 2019, 09:30 pm by rwhitenet
I'm using ESP8266's to create four time controlled switches.
When they try to get an ntpServer address using WiFi.hostByName(),
three of the IPAddresses I want to use for the devices return
a time server address, but the fourth fails with "us.pool.ntp.org: (IP unset)".
What do I need to do to make the fourth address succeed?

These are the addresses I'm sending to the ntp address servers:

  hostIP(192, 168, 1, 241)   succeeds
  hostIP(192, 168, 1, 242)   succeeds
  hostIP(192, 168, 1, 243)  *fails
  hostIP(192, 168, 1, 244)   succeeds

I would appreciate any thoughts.

This is the simplified code:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <stdio.h>
#include <string.h>

void setup()

  WiFiUDP Udp;
  WiFiServer server(80);

  Serial.print("\nConnecting to ");

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  WiFi.config(IPAddress(192, 168, 1, 243),
              IPAddress(192, 168, 1, 1),
              IPAddress(255, 255, 255, 0));

  Serial.println("\nWiFi connected.");


  IPAddress  ntpServerIP; // NTP server's ip address

  Serial.println("\nTransmit NTP Request");
  WiFi.hostByName("us.pool.ntp.org", ntpServerIP);
}  //Setup

void loop()
} // loop
Note: sorry the code section isn't in code format, but I couldn't find a way to delete it and start over.


Nov 23, 2019, 02:12 pm Last Edit: Nov 23, 2019, 02:12 pm by wildbill
What do you get if you ping the bad address from a command window on your PC?


Nov 23, 2019, 07:51 pm Last Edit: Nov 23, 2019, 08:10 pm by rwhitenet
Excellent question.

"Destination host unreachable"

I've also flushed the dns cache and am now going to restart the router.

Thank you for responding.

Subsequent edit: After I restarted the Comcast router it seems to have fixed it (for now).
You were definitely on the right track. Thanks.

Go Up