Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › automatic reboot

How to Make an ESP32 Automatically Reboot a Server When It Stops Responding

By Freedom251 Team · · 12 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An ESP32 can reboot a separate server only when three pieces work together: an independent controller, a health check that represents the service you care about, and an authorized recovery mechanism such as a server-management command or correctly selected power control. The ESP32’s own watchdog does not remotely restart another computer.

The reliable design is a state machine: poll the server, count consecutive failed checks, perform one compatible recovery action after a deliberate threshold, wait for the server to return, and suppress further actions until recovery has been evaluated.

As an Amazon Associate I earn from qualifying purchases.

Understand the two different watchdog jobs

Espressif describes a watchdog timer as a mechanism that monitors system operation and restarts the chip when it becomes unresponsive. The ESP32 watchdog therefore protects the ESP32 itself; it does not switch power to, log in to, or reset a separate server. See the ESP-IDF Watchdogs guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remote recovery requires a second control loop:

  • Observation: the ESP32 must reach a server endpoint and decide whether the endpoint reports a healthy service.
  • Decision: the controller must distinguish a real, persistent failure from a temporary DNS, Wi-Fi, routing, or application problem.
  • Action: it must invoke a recovery method accepted by that server, such as a management-interface reboot or a power-control device.

If the ESP32 and the server share the same power supply, a server power failure can also disable the monitor. Power the controller independently and place it on a network path that remains available when the server is down.

#1 Best Overall
ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores Microcontroller Processor Integrated with Antenna RF AMP Filter AP STA Compatible with Arduino IDE (3PCS)
  • 2.4GHz Dual Mode WiFi + Bluetooth Development Board
  • Support LWIP protocol, Freertos
  • SupportThree Modes: AP, STA, and AP+STA
  • Ultra-Low power consumption, Compatible with Arduino IDE
  • ESP32 is a safe, reliable, and scalable to a variety of applications

Choose how the server will recover

Do not select a relay or GPIO circuit before identifying the server’s model, input voltage, control interface, and electrical isolation requirements. The appropriate method depends on those details.

Recovery method What it can do Advantages Limitations and checks
Server management interface Requests an operating-system or hardware reset through an interface designed for remote administration. Can reboot the target without interrupting unrelated equipment; often provides status and audit information. Must be supported, reachable, authenticated, and configured for the exact server. A network outage may make the interface unavailable.
Supported remote power control Turns the server’s power input off and on through equipment intended for that load. Can recover a machine that no longer responds to software. Power interruption is disruptive. Verify voltage, current, inrush, switching method, isolation, and the server’s startup behavior.
Generic relay driven directly by an ESP32 pin May switch a control circuit when the relay module and load are electrically compatible. Simple in principle. Not universally safe or compatible. Pin current, flyback protection, isolation, contact ratings, mains safety, and enclosure requirements must be engineered for the installation.

Use a management interface when it can perform the needed reset and the network path is dependable. Use power control only when software recovery is insufficient and the switching hardware is explicitly rated for the server’s electrical conditions. If those requirements are unknown, stop at the health-monitoring portion rather than guessing at wiring.

Build an observable health check

Prefer an application endpoint

A successful ping or TCP connection proves only that some network stack answered. It does not prove that the database, web application, queue worker, or other service is ready. Create or select a small HTTP endpoint whose documented response means the target service is usable. The endpoint can return a simple success status and body after checking the dependencies that matter to the application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ESPHome’s HTTP Request component supports HTTP GET operations, response handling, and response timing. Treat the endpoint’s contract as part of the monitor: define which status code and body indicate health, and classify every other result as unhealthy or indeterminate according to your policy.

Keep the endpoint inexpensive and deterministic. It should perform the minimum dependency checks needed to establish readiness, avoid changing application data, and expose a response that the controller can classify consistently. If a service has separate liveness and readiness endpoints, use readiness for reboot decisions; liveness alone may only show that a process exists.

Set a finite timeout

The documented ESPHome HTTP-request timeout default is 4.5 seconds. On ESP32, that value applies separately to network operations such as DNS lookup, connection establishment, TLS handshake, and reads or writes; it is not necessarily one whole-request deadline. A request can therefore consume more elapsed time than a single 4.5-second interval when several operations fail in sequence.

Rank #2
ELEGOO 3PCS ESP-32 Dev Boards, ESP-WROOM-32, USB-C, WiFi Bluetooth 4.2 | Low-power IoT Applications, Smart Devices, Automation, Wireless Communication, GPIO Headers, Simplifying Development
  • Dual-Core Performance Up to 240 MHz: Run sensor processing, wireless communication, automation logic and connected-device tasks on a 32-bit dual-core ESP32 platform designed for responsive embedded and IoT projects
  • Built-in Wi-Fi and Bluetooth 4.2: Connect to 2.4 GHz Wi-Fi networks or use Bluetooth Classic and BLE for wireless sensors, smart devices, remote controls, home automation and other connected projects
  • Flexible Power-Saving Modes: ESP32 power-management features support dynamic clock scaling and low-power operating modes, helping developers reduce energy use in compatible sensing, monitoring and connected-device applications, suitable for battery-powered Internet of Things (IoT) devices.
  • USB-C Programming with CP2102: Connect through USB-C for power, sketch uploads and serial monitoring, while GPIO, UART, SPI and I2C interfaces support sensors, displays, motor drivers and other modules (USB-C cable not included)
  • Over-the-Air Update Support: Configure OTA functionality through a compatible ESP-32 software framework to update deployed firmware over Wi-Fi without reconnecting the board by USB for every revision

Choose an interval and timeout that fit the service’s normal latency, then require multiple consecutive failures. A single timeout can be caused by congestion or a transient Wi-Fi loss; it is not a universal proof that the server is down. Record the operation that timed out when the component exposes it, because a DNS failure points to a different remedy than an application response with an unhealthy status.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Authenticate without weakening TLS

Protect the health endpoint and recovery command with the least privilege available: a dedicated account, token, or management credential that cannot perform unrelated administration. Keep HTTPS certificate validation enabled on supported ESP32 builds. ESPHome warns that disabling verification can expose the connection to person-in-the-middle attacks. For a private server with a self-signed certificate, configure the appropriate CA certificate documented by the component instead of routinely setting verify_ssl: false.

Plan for certificate rotation as part of operations. An expired certificate, a missing intermediate, or an incorrect hostname should create a visible failed-check reason and an alert, not silently trigger an insecure fallback. Test the trust chain from the actual ESP32 firmware, since a certificate that works in a desktop browser may still require the correct CA configuration on the controller.

Implement the monitor as a state machine

The following sequence is portable across ESPHome and custom ESP-IDF firmware. Thresholds are deployment choices; there is no universal failure count supplied by the platform documentation.

  1. Start in a monitoring state. Record that no failure streak exists and that no recovery action is pending.
  2. Issue one health request. Use a finite timeout and the endpoint’s required authentication. Record status, elapsed time, and the type of failure if the request does not complete.
  3. Classify the result. A response that satisfies the endpoint contract is healthy. A timeout, DNS error, connection error, TLS-validation failure, unexpected status, or unhealthy body increments the failure streak according to your policy.
  4. Clear the streak on success. A healthy response resets consecutive failures to zero and records the recovery check as successful.
  5. Require a deliberate threshold. When the streak reaches your chosen number, verify that the monitor itself is not in a known network outage state, then invoke exactly one server-compatible recovery action.
  6. Enter a cooldown state. Do not issue another reboot immediately. Wait long enough for the server to shut down, start, initialize storage, and bring the application online.
  7. Verify recovery. Poll the same endpoint after the cooldown. Record whether the service returned and how many checks were needed.
  8. Escalate safely. If recovery failed, use a longer backoff, an alert, or a manual intervention path. Place a maximum action count in a time window so a faulty endpoint cannot create an endless reboot loop.
state = MONITORING
failures = 0
last_action = none

repeat every poll_interval:
    result = request_health_endpoint(timeout)

    if result.matches_health_contract:
        failures = 0
        log("healthy", result.status, result.duration)
        continue

    failures += 1
    log("failed", failures, result.error_or_status)

    if failures < failure_threshold:
        continue

    if action_count_in_window >= maximum_actions:
        alert_and_backoff()
        continue

    perform_authorized_server_recovery()
    log("recovery requested")
    wait recovery_cooldown
    action_count_in_window += 1
    failures = 0

The pseudocode intentionally leaves the recovery call abstract. Replace it with the server’s documented management API, a supported remote power controller, or other approved mechanism. Do not map a GPIO to a relay until the electrical design has been reviewed for the actual load.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use separate states for normal monitoring, suspected network failure, recovery pending, cooldown, and manual lockout when the installation warrants it. This prevents a delayed request from overlapping the next poll and makes it clear why an action was or was not taken. Persist only the state needed for safe restart behavior; an unexpected ESP32 reboot should not automatically repeat a recovery action whose outcome is unknown.

Rank #3
ELEGOO ESP-32 Super Starter Kit with Tutorial Compatible with Arduino IDE | Development Board, USB-C Dual Core Microcontroller Support AP/STA/AP+STA, CP2102 Chip, WiFi, Bluetooth, 200+ parts for IoT
  • Powerful ESP-32 Board: Unlock the world of Internet of Things (IoT) and advanced electronics with the heart of this kit: the ESP-32 board. It features a powerful dual-core processor, integrated Wi-Fi and Bluetooth 4.2, making it perfect for building connected, smart devices that communicate with your phone or the cloud. It's fully compatible with the Arduino IDE for easy programming.
  • Super Starter Kit: This kit contains over 35 different modules and electronic components, including sensors, displays, motors, and input devices. From LEDs and buttons to an OLED screen, servo motor, and keypad, you have everything needed to explore a vast range of projects in one box.
  • Step by Step Online Tutorial: Jump right in with our detailed, beginner-friendly tutorial. Access 30+ projects with complete code, clear circuit diagrams, and step-by-step instructions. Learn the fundamentals of electronics, coding, and how to utilize the ESP-32's unique capabilities without any prior experience.
  • Hands-on Learning for All Skill Levels: Perfect for students, makers, engineers, and hobbyists. Start with basic circuits and coding, then progress to intermediate and advanced IoT applications. Build practical projects like weather stations, smart home controllers, remote-controlled devices, and interactive gadgets. The skills you learn are the foundation for real-world innovation.
  • Quality & Great Support: Elegoo is committed to quality. We provide a clear, detailed tutorial guide, refined code, and a well-organized component kit. All modules are carefully selected for reliability and ease of use. Our dedicated technical support team and active online community are ready to help you succeed in your learning journey.

Configure ESPHome without confusing its own recovery features

In ESPHome, the HTTP request component is configured with a timeout and, for HTTPS, certificate-validation settings. Its actions run on the microcontroller. ESPHome documents that automations continue locally when Wi-Fi is down or MQTT is unreachable, although an HTTP request obviously cannot succeed without a usable route and name-resolution path.

HTTP requests execute on the main loop. The component’s watchdog_timeout option changes the watchdog timeout during connection and data transfer. ESPHome cautions against increasing it without observing watchdog-related reboots: a larger value can delay recovery from a legitimate firmware problem. Change it only after measuring the behavior and understanding the trade-off.

Implement the failure counter, cooldown, and action limit in local automation or firmware state. Keep logging local or buffered when possible, because an MQTT outage should not erase the evidence that a health check failed. When you do use a remote log sink, treat it as an aid rather than as a prerequisite for making the safety decision.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not mistake ESP32 watchdogs for server control

ESP-IDF provides an interrupt watchdog (IWDT) and task watchdog (TWDT) for stalled interrupt or task execution on the ESP32. They can reset the controller if its own firmware stops servicing critical work, but they do not send a reboot command to the monitored server.

ESPHome’s network or API reboot-timeout behavior similarly concerns the ESPHome device’s connectivity. It is not a health check proving that the target server is down. Safe mode has a different purpose as well: after repeated ESPHome boot failures, the documented default is ten failed boots before safe mode may be invoked; network and OTA remain available while most components are disabled. Safe mode cannot reboot the separate server. See ESPHome Safe Mode.

Make the network path dependable

Wi-Fi considerations

Place the ESP32 where it has stable coverage and a predictable local route to the server. Reserve its address or otherwise ensure that the health-check destination remains resolvable. Test behavior during access-point restarts, DHCP renewal, DNS failure, and a server outage; each can produce the same superficial symptom—a failed request—but requires a different response.

Rank #4
ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores Microcontroller Processor Integrated with Antenna RF AMP Filter AP STA Compatible with Arduino IDE (1 PCS)
  • 2.4GHz Dual Mode WiFi + Bluetooth Development Board
  • Support LWIP protocol, Freertos;ESP32 is a safe, reliable, and scalable to a variety of applications
  • SupportThree Modes: AP, STA, and AP+STA
  • Ultra-Low power consumption, Compatible with Arduino IDE
  • 1PCS 30Pin ESP32 Development Board 2.4GHz WiFi Dual Cores Microcontroller Integrated with Antenna RF Low Noise Amplifiers Filters

If the server and controller are on different network segments, verify routing and firewall rules for both the health endpoint and the recovery interface. A controller that can reach a web port but not a management port must not interpret the missing management path as proof that the server needs another reboot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ethernet considerations

A wired link can remove radio interference and improve reachability, but ESPHome Ethernet configuration depends on the controller, PHY, interface, and framework. Consult the Ethernet component documentation for the exact hardware. For SPI Ethernet, the documentation warns that flying leads or Dupont wires can fail because the interface uses a high-frequency clock; use an appropriate board layout and wiring rather than assuming any jumper arrangement will work.

Prevent false positives and reboot loops

Symptom Likely interpretation Design response
One request times out, then the next succeeds. Transient congestion, radio loss, DNS delay, or a busy server. Keep the server untouched; reset the failure streak after the healthy response.
Ping succeeds but the application is unusable. The host is reachable while the service or dependency is failing. Use an application-level endpoint with an explicit readiness contract.
Every request fails when the access point or DNS service is down. The monitor cannot distinguish a network fault from a server fault. Track network state separately, use a stable local address where appropriate, and require corroborating failures before an invasive action.
The server reboots repeatedly. The endpoint may be wrong, the threshold too low, startup may be slow, or the recovery action may not fix the fault. Add a long cooldown, cap actions per time window, log each result, and require manual review after the cap.
The ESP32 itself resets during requests. Firmware blocking, resource pressure, or watchdog timing may be involved. Inspect logs and measured request behavior before changing watchdog_timeout; do not hide a controller fault with an arbitrarily large timeout.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Test the complete failure and recovery path

  1. Run the health endpoint while the application is known to be healthy and verify that successful checks reset the counter.
  2. Stop only the application and confirm that the endpoint reports an unhealthy result even though the host still answers basic network traffic.
  3. Introduce a temporary network interruption and verify that the chosen policy does not immediately power-cycle the server.
  4. Allow enough consecutive failures to cross the threshold and confirm that exactly one authorized recovery action is issued.
  5. Measure the server’s actual boot and application-start time, then set the cooldown long enough to cover it.
  6. Simulate a failed recovery and confirm that the action cap, backoff, and alert path prevent repeated cycling.
  7. Restore normal operation and check that logs contain the failure count, result classification, action, cooldown, and recovery outcome.

Test the controller’s own power source separately. Unplugging the server must not reboot the ESP32, erase its state, or remove its network connection. Also test certificate-expiry and certificate-chain failures so that a security validation error is visible rather than silently converted into an unsafe bypass.

Security and electrical boundaries

  • Keep the recovery interface on a restricted network or VLAN when practical.
  • Use credentials dedicated to monitoring and recovery, and avoid embedding broad administrator credentials in firmware.
  • Protect tokens and certificates in the firmware and device-storage process used by your deployment.
  • Use HTTPS with validation and install the correct CA for private trust chains.
  • Never assume an ESP32 GPIO can switch a server’s supply directly. Select isolated, correctly rated power-control equipment and follow applicable electrical and mains-safety requirements.
  • Document a manual override so maintenance staff can prevent an automated reboot during diagnostics.

Practical design checklist

  • Is the ESP32 independently powered from the monitored server?
  • Does the endpoint represent application readiness rather than only ping reachability?
  • Are timeout semantics, DNS behavior, and TLS validation understood?
  • Are several consecutive failures required before action?
  • Is the recovery method supported by the exact server and its electrical/control interface?
  • Is there a cooldown, action cap, and backoff policy?
  • Are status, duration, failure cause, action, and recovery result recorded?
  • Have Wi-Fi, DNS, application, server-power, certificate, and ESP32-reset failures been tested separately?

With those conditions met, the ESP32 is a small, independent recovery controller rather than a misleading “watchdog setting.” Its watchdog protects the controller; its health-check state machine and authorized control path handle the separate server.

Frequently Asked Questions

Can the ESP32 watchdog reboot my server directly?

No. The ESP32 watchdog resets the ESP32 when its own firmware or system becomes unresponsive. Rebooting another computer requires a separate health check and an authorized server-management command or compatible power-control path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is ping enough to decide that a server is down?

No. Ping or a successful TCP connection shows only that part of the network stack responded. An application-level HTTP readiness endpoint is better because it can verify the service and important dependencies.

Best Value
HiLetgo ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores Microcontroller Processor Integrated with Antenna RF AMP Filter AP STA for Arduino IDE
  • 2.4GHz Dual Mode WiFi + Bluetooth Development Board
  • Ultra-Low power consumption, works perfectly with the Arduino IDE
  • Support LWIP protocol, Freertos
  • SupportThree Modes: AP, STA, and AP+STA
  • ESP32 is a safe, reliable, and scalable to a variety of applications

How many failed checks should trigger a reboot?

There is no universal number. Choose a consecutive-failure threshold from the service’s normal latency, network reliability, and the cost of an unnecessary reboot. Test transient Wi-Fi, DNS, and routing failures before enabling an invasive action.

Why did one 4.5-second ESPHome timeout take longer than 4.5 seconds?

ESPHome documents that on ESP32 the timeout applies separately to operations such as DNS, connection, TLS handshake, and reads or writes. Several operations can therefore consume more total elapsed time than one timeout value.

Should I set verify_ssl to false for a self-signed certificate?

Do not use that as a routine workaround. Keep certificate validation enabled and configure the appropriate CA certificate for the private trust chain. Disabling verification can expose the connection to person-in-the-middle attacks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What relay should I buy to power-cycle the server?

No single relay is universally suitable. The server’s voltage, current, inrush, switching method, isolation, enclosure, and applicable electrical-safety requirements must be known first. A supported management interface is often preferable because it avoids interrupting power.

What happens if Wi-Fi or MQTT is down?

ESPHome automations run locally and can continue even when Wi-Fi is down or MQTT is unreachable, but an HTTP request cannot succeed without a working route and name-resolution path. Design the policy so a network outage does not immediately create repeated server power cycles.

What is ESPHome safe mode for?

Safe mode is a recovery feature for repeated ESPHome boot failures, not a server reboot mechanism. Its documented default is ten failed boots before it may be invoked; network and OTA remain available while most components are disabled.

The Bottom Line

Build this as an independent monitor, not as a single watchdog setting: check an application-level endpoint, require consecutive failures, invoke only a server-compatible and authorized recovery method, then wait, verify, and cap further actions. Keep TLS validation, electrical safety, logging, and manual override in the design from the beginning.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

automatic rebootESP32ESPHomeIoTnetworkingServer Monitoringwatchdog

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.