ESP8266httpUpdate Issue PHP server


I am using the ESP8266httpUpdate library with the php example to communicate with the server and if the .bin file has a different md5, install the new .bin.

I can't get it to work, in arduino the serial monitor I get:

I get HTTP_UPDATE_FAILD Error (-104): Wrong HTTP Code
13: 04: 55.613 -> CALLBACK: HTTP update fatal error code -104

This is my PHP code:


header('Content-type: text/plain; charset=utf8', true);

function check_header($name, $value = false) {
    if(!isset($_SERVER[$name])) {
        return false;
    if($value && $_SERVER[$name] != $value) {
        return false;
    return true;

function sendFile($path) {
    header($_SERVER["SERVER_PROTOCOL"].' 200 OK', true, 200);
    header('Content-Type: application/octet-stream', true);
    header('Content-Disposition: attachment; filename='.basename($path));
    header('Content-Length: '.filesize($path), true);
    header('x-MD5: '.md5_file($path), true);

    !check_header('HTTP_X_ESP8266_STA_MAC') ||
    !check_header('HTTP_X_ESP8266_AP_MAC') ||
    !check_header('HTTP_X_ESP8266_FREE_SPACE') ||
    !check_header('HTTP_X_ESP8266_SKETCH_SIZE') ||
    !check_header('HTTP_X_ESP8266_SKETCH_MD5') ||
    !check_header('HTTP_X_ESP8266_CHIP_SIZE') ||
) {
    header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden', true, 403);
    echo "only for ESP8266 updater! (header)\n";

$localBinary = "/var/www/vhosts/";

// Check if version has been set and does not match, if not, check if
// MD5 hash between local binary and ESP8266 binary do not match if not.
// then no update has been found.
if(($_SERVER["HTTP_X_ESP8266_SKETCH_MD5"] != md5_file($localBinary)) {
} else {
    header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified', true, 304);

Maybe the problem is in the path of the localBinary .bin file, but I don't know how to solve it.

Thanks a lot

EDIT: acces_log file:

 [`14/Aug/2021:13:16:14 +0200] "GET /folder/arduino_check_updates.php HTTP/1.0" 500 177 "-" "ESP8266-http-Update"`

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.