[GH-ISSUE #1689] ESP32 fails to reset correctly after connecting to WIFI Network #1437

Closed
opened 2026-02-28 01:30:04 +03:00 by kerem · 5 comments
Owner

Originally created by @serifpersia on GitHub (Dec 19, 2023).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1689

Basic Infos

Latest release of WiFiManager from Arduino Library Manager

Hardware

Hardware: ESP32-12K(S2)

Core Version: 2.4.0

Description

Whenever I connect from captive portal to my local network, the esp32 doesn't reset correctly, and I get issue with not being able to connect to the webserver hosted on the esp32, the browser says device refuses to connect. When I press reset button on ESP32 I can access webserver hosted on esp32 ip or mdns, does this have to do with spiffs I assume.
Another minor thing I don't understand is ESP32 doesn't reset when users type wrong password for their ssid, you manually have to erase wifi config, typing correct password doesn't do anything. If you could clarify how that works.
Thanks!

Settings in IDE

Module: NodeMCU

Additional libraries:
#include <ESPAsyncWebServer.h>
#include <SPIFFS.h>

Sketch

#include <WiFiManager.h>
#include <ESPAsyncWebServer.h>
#include <SPIFFS.h>

AsyncWebServer server(80);

void setup() {
  Serial.begin(115200);

  // Initialize SPIFFS
  if (!SPIFFS.begin(true)) {
    Serial.println("An error occurred while mounting SPIFFS");
    return;
  }

  // WiFiManager
  WiFiManager wifiManager;

  if (!wifiManager.autoConnect("AutoConnectAP")) {
    Serial.println("Failed to connect and hit timeout");
  }

  // Route to serve HTML file
  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/index.html", "text/html");
  });

  // Route to serve CSS file
  server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/style.css", "text/css");
  });

  // Route to serve JavaScript file
  server.on("/script.js", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/script.js", "application/javascript");
  });

  // Start server
  server.begin();
}

void loop() {
}

Here is an image showing the browser, I checked with non spiffs site webserver and it still the same so its not spiffs. After I press reset button or reconnect power to esp32 only then I can connect to the ip of esp32 and access the page.
image

Originally created by @serifpersia on GitHub (Dec 19, 2023). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1689 ### Basic Infos Latest release of WiFiManager from Arduino Library Manager #### Hardware Hardware: ESP32-12K(S2) Core Version: 2.4.0 ### Description Whenever I connect from captive portal to my local network, the esp32 doesn't reset correctly, and I get issue with not being able to connect to the webserver hosted on the esp32, the browser says device refuses to connect. When I press reset button on ESP32 I can access webserver hosted on esp32 ip or mdns, does this have to do with spiffs I assume. Another minor thing I don't understand is ESP32 doesn't reset when users type wrong password for their ssid, you manually have to erase wifi config, typing correct password doesn't do anything. If you could clarify how that works. Thanks! ### Settings in IDE Module: NodeMCU Additional libraries: #include <ESPAsyncWebServer.h> #include <SPIFFS.h> ### Sketch ``` #include <WiFiManager.h> #include <ESPAsyncWebServer.h> #include <SPIFFS.h> AsyncWebServer server(80); void setup() { Serial.begin(115200); // Initialize SPIFFS if (!SPIFFS.begin(true)) { Serial.println("An error occurred while mounting SPIFFS"); return; } // WiFiManager WiFiManager wifiManager; if (!wifiManager.autoConnect("AutoConnectAP")) { Serial.println("Failed to connect and hit timeout"); } // Route to serve HTML file server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) { request->send(SPIFFS, "/index.html", "text/html"); }); // Route to serve CSS file server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest * request) { request->send(SPIFFS, "/style.css", "text/css"); }); // Route to serve JavaScript file server.on("/script.js", HTTP_GET, [](AsyncWebServerRequest * request) { request->send(SPIFFS, "/script.js", "application/javascript"); }); // Start server server.begin(); } void loop() { } ``` Here is an image showing the browser, I checked with non spiffs site webserver and it still the same so its not spiffs. After I press reset button or reconnect power to esp32 only then I can connect to the ip of esp32 and access the page. ![image](https://github.com/tzapu/WiFiManager/assets/62844718/5376ed20-4262-4669-9127-f2e023165f5e)
kerem closed this issue 2026-02-28 01:30:04 +03:00
Author
Owner

@serifpersia commented on GitHub (Dec 22, 2023):

I fixed this issue I had. I called the callback function on save config to restart esp32 board. I don't know why it doesn't do it automatically but this is the fix to be able to access the server without pressing reset button or reconnecting power to the board.

image

<!-- gh-comment-id:1867625398 --> @serifpersia commented on GitHub (Dec 22, 2023): I fixed this issue I had. I called the callback function on save config to restart esp32 board. I don't know why it doesn't do it automatically but this is the fix to be able to access the server without pressing reset button or reconnecting power to the board. ![image](https://github.com/tzapu/WiFiManager/assets/62844718/050fa1ac-b311-4c93-b93a-98c901e61ede)
Author
Owner

@tablatronix commented on GitHub (Dec 22, 2023):

What does your logs say?
Try increasing the retries for connect, this sounds like an ap issue.

Also there is esp bug that you cannot start a new webserver check your webserver error codes, the port stays in use and cannot be released

<!-- gh-comment-id:1867817115 --> @tablatronix commented on GitHub (Dec 22, 2023): What does your logs say? Try increasing the retries for connect, this sounds like an ap issue. Also there is esp bug that you cannot start a new webserver check your webserver error codes, the port stays in use and cannot be released
Author
Owner

@serifpersia commented on GitHub (Dec 22, 2023):

What does your logs say? Try increasing the retries for connect, this sounds like an ap issue.

Also there is esp bug that you cannot start a new webserver check your webserver error codes, the port stays in use and cannot be released

I found the fix I'm not going to go in depth on this I just wanted to have my webserver accessible immediately after connecting to local network via wifi manager. The image above does it for me. When a password is typed and save is pressed this runs and it resets the esp32 and it I can go into the ip without issue. One thing I hate is not having ability to know esp32's ip after connecting. Improv web serial sdk seems like a good option to setup wifi but for now I like using wifimanager library for wifi setup. And yes all esp32 devices i support s2 s3 and esp32 dev boards all have same symptom but luckily I found this quick fix for now. I will look into logs(enable verbose output on the core I assume?) Is this the esp bug you mentioned?

<!-- gh-comment-id:1867832704 --> @serifpersia commented on GitHub (Dec 22, 2023): > What does your logs say? Try increasing the retries for connect, this sounds like an ap issue. > > Also there is esp bug that you cannot start a new webserver check your webserver error codes, the port stays in use and cannot be released I found the fix I'm not going to go in depth on this I just wanted to have my webserver accessible immediately after connecting to local network via wifi manager. The image above does it for me. When a password is typed and save is pressed this runs and it resets the esp32 and it I can go into the ip without issue. One thing I hate is not having ability to know esp32's ip after connecting. Improv web serial sdk seems like a good option to setup wifi but for now I like using wifimanager library for wifi setup. And yes all esp32 devices i support s2 s3 and esp32 dev boards all have same symptom but luckily I found this quick fix for now. I will look into logs(enable verbose output on the core I assume?) Is this the esp bug you mentioned?
Author
Owner

@tablatronix commented on GitHub (Dec 22, 2023):

Yeah rebooting just frees the port I think, I bet if you use a different port it works, ie 8080

<!-- gh-comment-id:1867935849 --> @tablatronix commented on GitHub (Dec 22, 2023): Yeah rebooting just frees the port I think, I bet if you use a different port it works, ie 8080
Author
Owner

@serifpersia commented on GitHub (Dec 22, 2023):

Yeah rebooting just frees the port I think, I bet if you use a different port it works, ie 8080

Oh I see, well I will try different port for my webserver and see how it goes, since wifimanager webserver also uses port 80 and this bug is not releasing the port if I understood it correctly.

<!-- gh-comment-id:1867992930 --> @serifpersia commented on GitHub (Dec 22, 2023): > Yeah rebooting just frees the port I think, I bet if you use a different port it works, ie 8080 Oh I see, well I will try different port for my webserver and see how it goes, since wifimanager webserver also uses port 80 and this bug is not releasing the port if I understood it correctly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1437
No description provided.