some time connect with internet through wrong ssid in esp8266 code example
Example: esp wifi name
#include <ESP8266WiFi.h>
WiFi.hostname("Name");
set before WiFi.begin();
#include <ESP8266WiFi.h>
WiFi.hostname("Name");
set before WiFi.begin();