wifimanager ( bwssytems ) - strange behavior

Hello friends.

I am using an ESP32 as asyncWebserver. For the STA and AP handling i am using the Wifimanager.

Here is my code

#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager

AsyncWebServer server(80);

void setup() {
    // put your setup code here, to run once:

    //WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wm;
    wm.setShowDnsFields(true);  //reset settings - wipe credentials for testing

    // Automatically connect using saved credentials,
    // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
    // if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
    // then goes into a blocking loop awaiting configuration and will return success result

    bool res;
     res = wm.autoConnect(); // auto generated AP name from chipid
    // res = wm.autoConnect("AutoConnectAP"); // anonymous ap
    //res = wm.autoConnect("AutoConnectAP","mypassword"); // password protected ap

    if(!res) {
        Serial.println("Failed to connect");
        // ESP.restart();
    else {
        //if you get here you have connected to the WiFi    
        Serial.println("connected...yeey :)");

      // Receive an HTTP GET request
  server.on("/smsoff", HTTP_GET, [] (AsyncWebServerRequest *request) {
    request->send(200, "text/plain", "ok");



void loop() {
    // put your main code here, to run repeatedly:

I have noticed 2 strange error.

1): When i set the Wifi config in the AP, my ESp connects to the wifi. So far so good. But when i now do a hardreset, my ESP cant connecnt to WIFI and starts an AP. When i push again the hardresetbutton on ESP, i am connected to WIFI again. Push again ->opens AP. Push again-> Wifi is connected. And so on.

I tried 2 ESPs with the same reslut. My first intuation was, that it might be a router problem. So i set my mobile phone as an hotspot and the strange behavior is gone. Anyone an idea why this happens and what i can do against it?

  1. When i am using my mobilePhone as an hotspot and my esp is connected to it, i cant open my asncwebserver. When i am connected to my router, i can open my webpage.

Unfortunly my knowledge about networkissues is limited. Has someone encounterd the same issues?

Thank you very much

may be something to read here ?