0

The goal

I am trying to use mDNS as a means to obtain the IP address of an ESP32 webserver. (ESP32 Wroom32D using board = esp32doit-devkit-v1)

The problem

I can ping the microcontroller by its IP address, but cannot ping the microcontroller by its mDNS name. Windows 10 and Ubuntu terminal returns: Ping request could not find host esp32. Please check the name and try again. I also cannot access http://esp32.local/hello as would be expected failing the ping test

The code:

#include <Arduino.h>

#include <ESPmDNS.h>
#include <ESPAsyncWebServer.h>

const char* ssid = "my_ssid";
const char* password =  "my_password";

AsyncWebServer server(80);

void setup() {
  Serial.begin(115200);
  
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }
 
  if(!MDNS.begin("esp32")) {
     Serial.println("Error starting mDNS");
     return;
  }
  
  Serial.println(WiFi.localIP());
  
  server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/plain", "Hello World");
  });
  
  server.begin();
}

void loop(){}

Libraries

Can anyone give some indication of how to debug or resolve this issue?

Thank you

1 Answer 1

0

your ESP configuration is OK.

you can verify if Windows mDNS listener is enable : open a command prompt and type "netstat -an". looks at end of listing for UDP listening port 5353

UDP    192.168.X.Y:5353       *:*
UDP    [::1]:5353             *:*

if you don't find it, mDNS is not running and you can't discover hosts. as an alternative you can install Apple bonjour service here https://support.apple.com/kb/DL999?locale=fr_FR

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the information. My device does not appear in the list. Nor does [::1]:5353. May I ask you to unpack what you explained above a bit more. What is the [::1]:5353? Is port 5353 the default port for UDP packages?
I can confirm that I can ping the mDNS hostname from my Win11 laptop but not my Desktop. Thus the firmware is fine but my Desktop is not. How is this best resolved? Surely this feature is native to Win10?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.