The error during restart is because the server won't have been able to close instantly, but you are trying to recreate it on basically the next line. It's also possible the ESP8266 is taking a while to try and close all the active connections to the server...
You could try:
if (server) server.close();
server=undefined;
setTimeout(function() {
server = http.createServer(pageHandler);
....
}, 1000);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The error during restart is because the server won't have been able to close instantly, but you are trying to recreate it on basically the next line. It's also possible the ESP8266 is taking a while to try and close all the active connections to the server...
You could try: