esp8266 / esp8266/Arduino

OTA update with ESP failed, "connection refused" error appeared!

Open
#8,996 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

----------------------------- Delete below -----------------------------

"How can I fix the "connection refused" error when using the OTA update feature with the esp kit?",

#### Platform

- Hardware: [ESP-12|ESP-01|ESP-07|ESP8285 device|ESP32]
- Development Env: [Platformio]
- Operating System: [Ubuntu]

### Settings in IDE

- platform = espressif32
- board = esp32dev
- framework = arduino
- lib_extra_dirs = lib/libesp32
- monitor_speed = 115200
- board_build.f_cpu = 240000000L

### Problem Description

I have an ota link loaded into String ota_get_urllink = ""; before. For example: https://getOTA update link. On my computer, I can still access that link to download the file, but when using ESP, the DNS domain name cannot be resolved. The "connection refused" phenomenon still occurs from time to time. Many times ESP still downloads files successfully and updates successfully. Please tell me how to handle this problem?
Thank!

### [MCVE](https://stackoverflow.com/help/mcve) Sketch

```cpp

#include
#include
String ota_get_urllink = "https://getOTA"; //example link
void update() {
WiFiClientSecure client;
// WiFiClient client;
Serial.println("UpdateOTA.....");
// client.setCACert(rootCACertificate);
client.setInsecure();
client.setTimeout(240); //timeout 4 phut
httpUpdate.setLedPin(LED_BUILTIN_IR, LOW);
t_httpUpdate_return ret = httpUpdate.update(client, ota_get_urllink);
switch (ret) {
case HTTP_UPDATE_FAILED: //ret = 0
Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());

break;
case HTTP_UPDATE_NO_UPDATES: //ret = 1
Serial.println("HTTP_UPDATE_NO_UPDATES");
break;

case HTTP_UPDATE_OK: //ret = 2
Serial.println("HTTP_UPDATE_OK");
break;
}
}

```

### Debug Messages
HTTP_UPDATE_FAILD Error (-1): HTTP error: connection refused
```
HTTP_UPDATE_FAILD Error (-1): HTTP error: connection refused
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.