Wifi RTC not working

I am working with this tutorial https://www.arduino.cc/en/Tutorial/WiFiRTC but when I upload it it gets stuck in this loop:

unsigned long epoch;
  int numberOfTries = 0, maxTries = 6;
  do {
    epoch = readLinuxEpochUsingNTP();
    numberOfTries++;
  }
  while ((epoch == 0) || (numberOfTries > maxTries));

  if (numberOfTries > maxTries) {
    Serial.print("NTP unreachable!!");
    while (1);
  }
  else {
    Serial.print("Epoch received: ");
    Serial.println(epoch);
    rtc.setEpoch(epoch);

    Serial.println();
  }

And it loops more than 6 times, it loops infinitely. And I am sure that it is connected to a Wifi network with internet access. Is there a problem with this tutorial?

Compiles and runs fine here directly from the tutorial.

Did you change any of the code (apart from ssid and password) ?
Does it fail right away or after a while ?

If its after a while you are subject the a known MKR bug that seems linked to the serial output and as yet I have not found a cure despite a lot of testing.

The other thing maybe a firewall / port issue at your end either in house or at your ISP seeing as you seem to be hitting the max re-tries ?

Win 7 X64 here btw working with or without VPN connection

How did you isolate the specific section of code as the issue ?

probably found a solution to this problem at this topic:

https://forum.arduino.cc/index.php?topic=449906.0