[GH-ISSUE #1579] Web Server doesn't starts after Wifi connected through WiFiManager #1348

Closed
opened 2026-02-28 01:29:42 +03:00 by kerem · 21 comments
Owner

Originally created by @patelabhi23 on GitHub (Mar 29, 2023).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1579

I am using ESP32 Wroom DA module. When I connect to the WiFi Manager AP & then save new WiFi credentials then the Web Server doesn't starts. It gets the IP & Internet Connection but when I open WebServer HTTTP404 error. I am using AsyncWebServer instead of the WebServer.

Currently, if I do hard reset of the ESP then the WebServer starts working, but instead of Hard Reset on ESP I would like to do with the code itself.

Originally created by @patelabhi23 on GitHub (Mar 29, 2023). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1579 I am using ESP32 Wroom DA module. When I connect to the WiFi Manager AP & then save new WiFi credentials then the Web Server doesn't starts. It gets the IP & Internet Connection but when I open WebServer HTTTP404 error. I am using AsyncWebServer instead of the WebServer. Currently, if I do hard reset of the ESP then the WebServer starts working, but instead of Hard Reset on ESP I would like to do with the code itself.
kerem 2026-02-28 01:29:42 +03:00
Author
Owner

@Bighoneypot commented on GitHub (Mar 29, 2023):

@patelabhi23 can you paste your full code and write your the result you expected?

<!-- gh-comment-id:1488338135 --> @Bighoneypot commented on GitHub (Mar 29, 2023): @patelabhi23 can you paste your full code and write your the result you expected?
Author
Owner

@patelabhi23 commented on GitHub (Mar 29, 2023):

@Bighoneypot yes here is the code:

#include <WiFiManager.h>
WiFiManager wm;
#include "ESPAsyncWebServer.h"

AsyncWebServer server ( 80 );

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

  wm.resetSettings();

  bool res;
  res = wm.autoConnect("Abc", "123"); 

  if (!res) {
    Serial.println("Failed to connect");
  }
  else {
    Serial.println("connected...yeey :)");
    ESP.restart();
  }

}

void beginServer()
{
  server.reset();

  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(200, "text/html", webPage());
    delay(1000);
    ESP.restart();
  });
  server.begin();
  Serial.println ( "HTTP server started" );
}

void loop() {
  Serial.println(WiFi.localIP());
  beginServer();
  delay(5000);
}

String webPage() {
  String ptr = "<!DOCTYPE html> <html>\n";
  ptr += "<body>\n";
  ptr += "<p>Hello World</p>";
  ptr += "</body>\n";
  ptr += "</html>\n";
  return ptr;
}

Once the Wifi is configured then it prints the IP address but when I open the webpage using that IP it shows that "This site can't be reached"

image

<!-- gh-comment-id:1488509431 --> @patelabhi23 commented on GitHub (Mar 29, 2023): @Bighoneypot yes here is the code: ``` #include <WiFiManager.h> WiFiManager wm; #include "ESPAsyncWebServer.h" AsyncWebServer server ( 80 ); void setup() { Serial.begin(9600); wm.resetSettings(); bool res; res = wm.autoConnect("Abc", "123"); if (!res) { Serial.println("Failed to connect"); } else { Serial.println("connected...yeey :)"); ESP.restart(); } } void beginServer() { server.reset(); server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) { request->send(200, "text/html", webPage()); delay(1000); ESP.restart(); }); server.begin(); Serial.println ( "HTTP server started" ); } void loop() { Serial.println(WiFi.localIP()); beginServer(); delay(5000); } String webPage() { String ptr = "<!DOCTYPE html> <html>\n"; ptr += "<body>\n"; ptr += "<p>Hello World</p>"; ptr += "</body>\n"; ptr += "</html>\n"; return ptr; } ``` Once the Wifi is configured then it prints the IP address but when I open the webpage using that IP it shows that "This site can't be reached" ![image](https://user-images.githubusercontent.com/65539389/228534166-b06a6138-060a-4dce-8a9a-f1eb9bde4c05.png)
Author
Owner

@tablatronix commented on GitHub (Mar 29, 2023):

There is a problem in esp with reopening a port for example opening another webserver even after one is closed. There is an issue we never figured it out

<!-- gh-comment-id:1488544303 --> @tablatronix commented on GitHub (Mar 29, 2023): There is a problem in esp with reopening a port for example opening another webserver even after one is closed. There is an issue we never figured it out
Author
Owner

@patelabhi23 commented on GitHub (Mar 29, 2023):

@tablatronix
I am using the below attached ESP32 Board

image

Also I have tried doing the same in other ESP boards as if this ESP board might be damaged but it wasn't the case. In multiple ESP boards I have faced the same issue.

I have also gone through the #545 where you have resolved for the simple WebServer and not the AsyncWebServer.

<!-- gh-comment-id:1488558487 --> @patelabhi23 commented on GitHub (Mar 29, 2023): @tablatronix I am using the below attached ESP32 Board ![image](https://user-images.githubusercontent.com/65539389/228541803-171962e7-0ec3-4568-8c8c-78acacd487ec.png) Also I have tried doing the same in other ESP boards as if this ESP board might be damaged but it wasn't the case. In multiple ESP boards I have faced the same issue. I have also gone through the #545 where you have resolved for the simple WebServer and not the AsyncWebServer.
Author
Owner

@tablatronix commented on GitHub (Mar 29, 2023):

Yeah you cannot run 2 webservers even if you close one the port is not free have to reatart

<!-- gh-comment-id:1488686695 --> @tablatronix commented on GitHub (Mar 29, 2023): Yeah you cannot run 2 webservers even if you close one the port is not free have to reatart
Author
Owner

@patelabhi23 commented on GitHub (Mar 29, 2023):

So you mean to say that wifimanager library doesn't supports two webservers?

<!-- gh-comment-id:1488694451 --> @patelabhi23 commented on GitHub (Mar 29, 2023): So you mean to say that wifimanager library doesn't supports two webservers?
Author
Owner

@Bighoneypot commented on GitHub (Mar 29, 2023):

Yeah you cannot run 2 webservers even if you close one the port is not free have to reatart

This is the problem, you can't run 2 webservers @patelabhi23

<!-- gh-comment-id:1488764861 --> @Bighoneypot commented on GitHub (Mar 29, 2023): > Yeah you cannot run 2 webservers even if you close one the port is not free have to reatart This is the problem, you can't run 2 webservers @patelabhi23
Author
Owner

@patelabhi23 commented on GitHub (Mar 29, 2023):

@Bighoneypot I am closing the same port & again reopening it then too why it isn't working. Also you have the option of multiple ports in ESP32 & I am running multiple ports by saving the Wifi credentials in the code, but once I integrate wifimanager everything stops out

<!-- gh-comment-id:1488788889 --> @patelabhi23 commented on GitHub (Mar 29, 2023): @Bighoneypot I am closing the same port & again reopening it then too why it isn't working. Also you have the option of multiple ports in ESP32 & I am running multiple ports by saving the Wifi credentials in the code, but once I integrate wifimanager everything stops out
Author
Owner

@tablatronix commented on GitHub (Mar 29, 2023):

Its an ESP BUG! ports are not released, run it on a different port I bet it works, or restart if the portal was started

<!-- gh-comment-id:1488885644 --> @tablatronix commented on GitHub (Mar 29, 2023): Its an ESP BUG! ports are not released, run it on a different port I bet it works, or restart if the portal was started
Author
Owner

@patelabhi23 commented on GitHub (Mar 29, 2023):

@tablatronix

  1. could you suggest any solution on how to solve that esp bug or even how to debug that?
  2. I have already added the esp restart in the snippet above but then too it isn't working, so any alternatives for that?
<!-- gh-comment-id:1488959982 --> @patelabhi23 commented on GitHub (Mar 29, 2023): @tablatronix 1. could you suggest any solution on how to solve that esp bug or even how to debug that? 2. I have already added the esp restart in the snippet above but then too it isn't working, so any alternatives for that?
Author
Owner

@tablatronix commented on GitHub (Mar 31, 2023):

Its deep inside the wifiserver library, I am not very familiar with it but I never figured out or even got anywhere.

There might be a conflict between async and regular webserver libraries also , have you tried running both without wm?
I am working on the async branch to get it switchable

<!-- gh-comment-id:1491170270 --> @tablatronix commented on GitHub (Mar 31, 2023): Its deep inside the wifiserver library, I am not very familiar with it but I never figured out or even got anywhere. There might be a conflict between async and regular webserver libraries also , have you tried running both without wm? I am working on the async branch to get it switchable
Author
Owner

@patelabhi23 commented on GitHub (Mar 31, 2023):

Yes when I run without wm both of them works well but on integrating with wm it causes issue.

Also the esp.restart isn't working in that case so any alternatives for that?

<!-- gh-comment-id:1491280735 --> @patelabhi23 commented on GitHub (Mar 31, 2023): Yes when I run without wm both of them works well but on integrating with wm it causes issue. Also the esp.restart isn't working in that case so any alternatives for that?
Author
Owner

@patelabhi23 commented on GitHub (May 1, 2023):

@tablatronix as per this were you able to make the async branch switchable?

Its deep inside the wifiserver library, I am not very familiar with it but I never figured out or even got anywhere.

There might be a conflict between async and regular webserver libraries also , have you tried running both without wm? I am working on the async branch to get it switchable

<!-- gh-comment-id:1529599815 --> @patelabhi23 commented on GitHub (May 1, 2023): @tablatronix as per this were you able to make the async branch switchable? > Its deep inside the wifiserver library, I am not very familiar with it but I never figured out or even got anywhere. > > There might be a conflict between async and regular webserver libraries also , have you tried running both without wm? I am working on the async branch to get it switchable
Author
Owner

@tablatronix commented on GitHub (May 1, 2023):

No but I will try to get some traction on it this week and try to get some releases out

<!-- gh-comment-id:1530530522 --> @tablatronix commented on GitHub (May 1, 2023): No but I will try to get some traction on it this week and try to get some releases out
Author
Owner

@SVLoneStar commented on GitHub (May 8, 2023):

Any news on this?
Alternatively...is there a way to start WifiManager listening on a port other than 80? Thx!

<!-- gh-comment-id:1539024826 --> @SVLoneStar commented on GitHub (May 8, 2023): Any news on this? Alternatively...is there a way to start WifiManager listening on a port other than 80? Thx!
Author
Owner

@patelabhi23 commented on GitHub (May 10, 2023):

No not any yet as the asyncwebserver trys to reopen the same port but it isn't being able to do so.

Any news on this? Alternatively...is there a way to start WifiManager listening on a port other than 80? Thx!

<!-- gh-comment-id:1541376069 --> @patelabhi23 commented on GitHub (May 10, 2023): No not any yet as the asyncwebserver trys to reopen the same port but it isn't being able to do so. > Any news on this? Alternatively...is there a way to start WifiManager listening on a port other than 80? Thx!
Author
Owner

@patelabhi23 commented on GitHub (May 10, 2023):

@tablatronix any updates?

No but I will try to get some traction on it this week and try to get some releases out

<!-- gh-comment-id:1541376832 --> @patelabhi23 commented on GitHub (May 10, 2023): @tablatronix any updates? > No but I will try to get some traction on it this week and try to get some releases out
Author
Owner

@tablatronix commented on GitHub (May 11, 2023):

#1121

<!-- gh-comment-id:1544426209 --> @tablatronix commented on GitHub (May 11, 2023): #1121
Author
Owner

@kjyv commented on GitHub (May 29, 2023):

Why was this closed? The bug is still there and the linked ticket seems related, but is not a duplicate or superset of this one

<!-- gh-comment-id:1567123500 --> @kjyv commented on GitHub (May 29, 2023): Why was this closed? The bug is still there and the linked ticket seems related, but is not a duplicate or superset of this one
Author
Owner

@tablatronix commented on GitHub (May 29, 2023):

Because its a bug In ESP not wm, and i have no workaround for it

<!-- gh-comment-id:1567202490 --> @tablatronix commented on GitHub (May 29, 2023): Because its a bug In ESP not wm, and i have no workaround for it
Author
Owner

@khoint2101 commented on GitHub (Jun 12, 2023):

Bất kỳ tin tức về điều này? Ngoài ra... có cách nào để bắt đầu nghe WifiManager trên cổng khác 80 không? Thx!

Any news on this? Alternatively...is there a way to start WifiManager listening on a port other than 80? Thx!

You can open custom port for WM lib. You can use to
WiFiManager wm; wm.setHttpPort(8080);
This is open port 8080 for wifimanager web config, but when you login to wifi, you must type: 192.168.4.1:8080 to open web.
When using the other port, webserver will start after success config wifi. DON'T NEED Hard Reset :>

<!-- gh-comment-id:1587107763 --> @khoint2101 commented on GitHub (Jun 12, 2023): > Bất kỳ tin tức về điều này? Ngoài ra... có cách nào để bắt đầu nghe WifiManager trên cổng khác 80 không? Thx! > Any news on this? Alternatively...is there a way to start WifiManager listening on a port other than 80? Thx! You can open custom port for WM lib. You can use to `WiFiManager wm; wm.setHttpPort(8080); ` This is open port 8080 for wifimanager web config, but when you login to wifi, you must type: 192.168.4.1:8080 to open web. When using the other port, webserver will start after success config wifi. DON'T NEED Hard Reset :>
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#1348
No description provided.