Crashing of ESP8266WebServer.h

I’m having problems with my ESP8266’s web serving abilities. Currently if I start it up and try to access the web page it loads a few times and works as it should but then just stops responding. The number of times it works varies from one to zero. If i leave it for a time it will stop responding on its own and eventually it reboots on its own.

Any suggestions of how to debug? My serial output is still working as it displays the NTP but once the server stops responding it no longer shows a tick per second its closer to 10s. The server must be waiting for something??

This is skeleton code extracted from the project

#include <Adafruit_NeoPixel.h>
#include <TimeLib.h> 
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include "WebPage.h"
#include <ESP8266WebServer.h>
#include <NTPClient.h>
#define PIN            12
#define NUMPIXELS      256//new root handler

void setup() {   
  Serial.println("TimeNTP Example");
  Serial.print("Connecting to ");
  WiFi.begin(ssid, pass);
    while (WiFi.status() != WL_CONNECTED) {
  Serial.print("IP number assigned by DHCP is ");
  Serial.println("Starting UDP");
  Serial.print("Local port: ");
  Serial.println("waiting for sync");
  //for DST
  timeZone = DST(); 
  //start display pixels

  //start web server
  server.on("/", handleRoot);
  server.on("/submit", handleSubmit);
  Serial.println("Starting Web Server");
  Serial.print("Connect to http://");
  void loop() {
    // Display Stuff
    //Web Interface
    //SHow time only if seconds changed
    if (now() != prevDisplay) { //update the display only if time has changed
      prevDisplay = now();
void handleRoot()
  if (server.hasArg("line")) {
  else {
    server.send(200, "text/html", INDEX_HTML);
   Serial.println("SERVER HANDLER USED");

void handleNotFound()
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  server.send(404, "text/plain", message);

void handleSubmit()

  if (!server.hasArg("line")) return returnFail("BAD ARGS");
    command = server.arg("line");
    server.send(200, "text/html", "SUCCESS");

  void returnFail(String msg)
  server.sendHeader("Connection", "close");
  server.sendHeader("Access-Control-Allow-Origin", "*");
  server.send(500, "text/plain", msg + "\r\n");

and webpage.h

#ifndef header_h
#define header_h

const char INDEX_HTML[]=
"<!DOCTYPE html>\r\n"
"<html lang=\"en\">\r\n"
"    <head>\r\n"
"        <meta charset=\"utf-8\">\r\n"
"        <title>Clock Command</title>\r\n"
"    </head>\r\n"
"    <body \">\r\n"
"<FORM action=\"/\" method=\"post\">"
"        <p><b>Enter a command string</b></p>\r\n"
"        <form id=\"txt_form\" name=\"frmText\">\r\n"
"            <label>Text: <input type=\"text\" name=\"line\" size=\"60\" maxlength=\"60\" /></label>\r\n"
"        </form>\r\n"
"        <input type=\"submit\" value=\"Send\"> <INPUT type=\"reset\">\r\n"
"    </body>\r\n"

and webpage.h

Code: [Select]

ifndef header_h

define header_h

The name in the include guard is SUPPOSED to match the name of the file.

const char INDEX_HTML[]=

It may be const, but it still occupies SRAM.

#define NUMPIXELS      256//new root handler

Are you using the ESP with 2 terabytes of memory?

The ESP may have more memory, but you are making no attempts to keep data out of SRAM.

Lol no it's a node mcu so standard sram (I don't actually know how much?!). Actually a lot of other things are stored in eeprom.

Do you think it's just a ram issue? I can easily move the webpage to eeprom. The neopixel library does use up a fair bit but I've tried and struggled to make it smaller in the past for a nano.

I don't actually know how much?

Why don't you? They do not ship with random amounts of memory. Learn how much yours has.

Do you think it's just a ram issue?

It's certainly a possibility.

I can easily move the webpage to eeprom.

I think (or hope) you meant PROGMEM.

Show all your code except for maybe your wifi credentials.
You appear to be missing a section which would include:
ESP8266WebServer server ( );