Trying to build Async Web server

Been trying to get this web server up and running, I cut and pasted a sketch from the web, it compiles and loads just fine .When I try to run it in Serial monitor i get " WiFi Connecting " but it never connects.I wrote to the author and they don’t seem to understand the reason for it not working.
What I have tried :
I loaded a example sketch from the Arduino Ide WiFi Scan and it worked just fine, saw 3 of my networks best was (-29) so I know I am close enough

I loaded this sketch on 3 different boards and none will get past “Wifi connection”

I am in the same room as the wireless router, 5’ away so it can’t be distance.

I have double checked credentials and made sure it is at 115200 BPS
Here is the code, hope you can help me ;

  Rui Santos
  Complete project details at
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

// Import required libraries
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>

// Replace with your network credentials
const char* ssid = "********";
const char* password = "********";

const char* PARAM_INPUT_1 = "output";
const char* PARAM_INPUT_2 = "state";

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

const char index_html[] PROGMEM = R"rawliteral(
  <title>ESP Web Server</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" href="data:,">
    html {font-family: Arial; display: inline-block; text-align: center;}
    h2 {font-size: 3.0rem;}
    p {font-size: 3.0rem;}
    body {max-width: 600px; margin:0px auto; padding-bottom: 25px;}
    .switch {position: relative; display: inline-block; width: 120px; height: 68px} 
    .switch input {display: none}
    .slider {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
    .slider:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
    input:checked+.slider {background-color: #b30000}
    input:checked+.slider:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
  <h2>ESP Web Server</h2>
<script>function toggleCheckbox(element) {
  var xhr = new XMLHttpRequest();
  if(element.checked){"GET", "/update?output=""&state=1", true); }
  else {"GET", "/update?output=""&state=0", true); }

// Replaces placeholder with button section in your web page
String processor(const String& var){
    String buttons = "";
    buttons += "<h4>Output - GPIO 5</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"5\" " + outputState(5) + "><span class=\"slider\"></span></label>";
    buttons += "<h4>Output - GPIO 4</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"4\" " + outputState(4) + "><span class=\"slider\"></span></label>";
    buttons += "<h4>Output - GPIO 2</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"2\" " + outputState(2) + "><span class=\"slider\"></span></label>";
    return buttons;
  return String();

String outputState(int output){
    return "checked";
  else {
    return "";

void setup(){
  // Serial port for debugging purposes

  pinMode(5, OUTPUT);
  digitalWrite(5, LOW);
  pinMode(4, OUTPUT);
  digitalWrite(4, LOW);
  pinMode(2, OUTPUT);
  digitalWrite(2, LOW);
  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Connecting to WiFi..");

  // Print ESP Local IP Address

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/html", index_html, processor);

  // Send a GET request to <ESP_IP>/update?output=<inputMessage1>&state=<inputMessage2>
  server.on("/update", HTTP_GET, [] (AsyncWebServerRequest *request) {
    String inputMessage1;
    String inputMessage2;
    // GET input1 value on <ESP_IP>/update?output=<inputMessage1>&state=<inputMessage2>
    if (request->hasParam(PARAM_INPUT_1) && request->hasParam(PARAM_INPUT_2)) {
      inputMessage1 = request->getParam(PARAM_INPUT_1)->value();
      inputMessage2 = request->getParam(PARAM_INPUT_2)->value();
      digitalWrite(inputMessage1.toInt(), inputMessage2.toInt());
    else {
      inputMessage1 = "No message sent";
      inputMessage2 = "No message sent";
    Serial.print("GPIO: ");
    Serial.print(" - Set to: ");
    request->send(200, "text/plain", "OK");

  // Start server

void loop() {


I have used this code and it works great. Your problem sounds like the following, missing or bad ssid and or password.
You have to tell it what to do. the const char* ssid = ""; needs you to put in your own ssid, If you do not know it, you can go into your router admin, and see what it is. You need to also tell it what the password is: const char* password = "";. The number of characters depends on what your arguments are, they are not fixed length fields.
const char* ssid = "WL1"; Network Name
const char* password = "ZIPER";. Network Password
You have to give this info to other devices to make them connect.

I just didn't leave my credentials in the code posted, wasn't sure if it was something that should be written .I supposed i should have put something like "Mynetwork" and "password". So I am positive that it is not that, i use my credentials on other wifi programs and know it has to be input correctly. That is why I am at such a loss here ,I have tried this on 3 different boards as I said above and always the same result. I press the reset button , get the same results ,"connecting to WiFi" but it never does. The fact that I used 3 different boards would suggest it is not a board issue.I believe it uses port 80 , could it be blocked and if that is the case what port could I use instead.I really don't know anything about this stuff, still trying to learn, Thanks

Can you try a simpler sketch just to see if it is something in the sketch e.g. the one shown on this page: ESP8266WiFi library — ESP8266 Arduino Core 3.0.0-12-gbf6f3e7c documentation

How long have you waited one seing the first "Connecting to WiF.."?
Do you know what security is being used on your router?
If your router is dual band ie 2.4GHz and 5GHz try disabling the 5GHz and see whether that allows the connecton.
There is also a WiFi scan sketch you can download which will allow you to scan and wee what WIFI networks he esp266 can actually see.