-
Notifications
You must be signed in to change notification settings - Fork 87
Description
Platform
ESP32
IDE / Tooling
Arduino (IDE/CLI)
What happened?
When running the example program EndBegin.ino, I connected to the ESP32's WiFi and accessed http://192.168.4.1/ using a browser. While continuously refreshing the webpage, the program encountered the following error when executing server.begin() for the second time:
[20615][E][AsyncTCP.cpp:1521] begin(): bind error: -8.
At this point, the webpage returned net::ERR_CONNECTION_REFUSED.
I suspect this is caused by a port conflict. How can I resolve this issue?
Stack Trace
Software Info:
Compile Date/Time : Nov 21 2025 20:19:26
Compile Host OS : windows
ESP-IDF Version : v5.5.1-710-g8410210c9a
Arduino Version : 3.3.4
Board Info:
Arduino Board : ESP32S3_DEV
Arduino Variant : esp32s3
Arduino FQBN : esp32:esp32:esp32s3:UploadSpeed=921600,USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=240,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=verbose,PSRAM=disabled,LoopCore=1,EventsCore=1,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default
[ 361][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 44 successfully set to type UART_RX (2) with bus 0x3fc95e10
[ 372][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42010d9c
[ 383][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 43 successfully set to type UART_TX (3) with bus 0x3fc95e10
[ 394][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42010d68
[ 405][V][esp32-hal-uart.c:716] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(44) txPin(43)
[ 414][V][esp32-hal-uart.c:814] uartBegin(): UART0 not installed. Starting installation
[ 422][V][esp32-hal-uart.c:824] uartBegin(): UART0 RX FIFO full threshold set to 120 (value requested: 120 || FIFO Max = 128)
[ 433][V][esp32-hal-uart.c:850] uartBegin(): Setting UART0 to use XTAL clock
[ 440][V][esp32-hal-uart.c:889] uartBegin(): UART0: RX and TX signals are set not inverted.
[ 449][V][esp32-hal-uart.c:917] uartBegin(): UART0 initialization done.
[ 455][V][esp32-hal-uart.c:968] uartSetRxFIFOFull(): UART0 RX FIFO Full value set to 120 from a requested value of 120
[ 480][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 101 - WIFI_READY
[ 596][V][AP.cpp:108] _onApEvent(): AP Started
[ 600][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 130 - AP_START
[ 608][V][AP.cpp:88] _onApArduinoEvent(): Arduino AP Event: 130 - AP_START
begin() - run: curl -v http://192.168.4.1/ => should succeed
[ 7806][V][AP.cpp:125] _onApEvent(): AP Station Connected: MAC: fa:20:6a:98:97:22, AID: 1
[ 7814][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 132 - AP_STACONNECTED
[ 7822][V][AP.cpp:88] _onApArduinoEvent(): Arduino AP Event: 132 - AP_STACONNECTED
[ 8198][V][NetworkInterface.cpp:146] _onIpEvent(): ap Assigned IP: 192.168.4.2 to MAC: FA:20:6A:98:97:22
[ 8207][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 134 - AP_STAIPASSIGNED
[ 8215][V][AP.cpp:88] _onApArduinoEvent(): Arduino AP Event: 134 - AP_STAIPASSIGNED
end()
[ 20615][E][AsyncTCP.cpp:1521] begin(): bind error: -8
begin() - run: curl -v http://192.168.4.1/ => should succeed
Minimal Reproductible Example (MRE)
#include <Arduino.h>
#if defined(ESP32) || defined(LIBRETINY)
#include <AsyncTCP.h>
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
#include <RPAsyncTCP.h>
#include <WiFi.h>
#endif
#include <ESPAsyncWebServer.h>
static AsyncWebServer server(80);
void setup() {
Serial.begin(115200);
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED || LT_ARD_HAS_WIFI || CONFIG_ESP32_WIFI_ENABLED
WiFi.mode(WIFI_AP);
WiFi.softAP("esp-captive");
#endif
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", "Hello, world");
});
server.begin();
Serial.println("begin() - run: curl -v http://192.168.4.1/ => should succeed");
delay(20000);
// Connect to the WiFi and continuously access http://192.168.4.1/ during this period.
Serial.println("end()");
server.end();
server.begin();
// The error message [ 20615][E][AsyncTCP.cpp:1521] begin(): bind error: -8 appeared, and the web page could no longer be accessed.
Serial.println("begin() - run: curl -v http://192.168.4.1/ => should succeed");
}
// not needed
void loop() {
delay(100);
}
I confirm that:
- I have read the documentation.
- I have searched for similar discussions.
- I have searched for similar issues.
- I have looked at the examples.
- I have upgraded to the lasted version of ESPAsyncWebServer (and AsyncTCP for ESP32).