How to fix Arduino [WiFiUdp.cpp:183] endPacket(): could not send data: 118
When you see a log message like
[ 13701][E][WiFiUdp.cpp:183] endPacket(): could not send data: 118
on your microcontroller, you can use Serial.println(strerror(118));
to find out what the error code 118
means.
In the case of 118
(tested with arduino-espressif32
v2.0.5
) the error means
Host unreachable
Typically, this error means that you are not connected to the internet / network but it might also mean that the
Note that the error message by itself does not give any indication what part of your code tried to send the UDP packet - hence, it’s not immediately clear what host specifically can’t be reached. However, this message specifically happens with code that sends UDP packets. In almost all cases, the error won’t happen when the microcontroller responds to UDP packets from another host (such as ArduinoOTA
) but when the microcontroller tries to send packets to the network initiated by the microcontroller itself (such as NTP
).