I am trying to make an HTTP request over WiFi from an ESP32, but upon connecting to the host, this error is displayed in serial console
[ 21036][E][WiFiGeneric.cpp:1230] hostByName(): DNS Failed for httpbin.org
The code is as follows (PlatformIO C++ using the Arduino framework)
const char *ssid = "Nebula's iPhone";
const char *password = "password";
const char *host = "httpbin.org";
...
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_OFF);
delay(1000);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (!WiFi.isConnected()) {
delay(100);
}
WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(),
IPAddress(1, 1, 1, 1), IPAddress(8, 8, 8, 8));
}
...
void makeRequest() {
httpsClient.connect(host, 443); // Fails here
}