ESP32 TCP Client Connection Refused
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 TCP Client Connection Refused. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 TCP client cannot connect to a TCP server — connection refused or timeout.
Quick Fix
Wrong
WiFiClient client;
client.connect("192.168.1.100", 5000);
client.print("Hello");
[E][WiFiClient.cpp:315] connect(): Connection refused errno 111
Right
WiFiClient client;
if (client.connect("192.168.1.100", 5000, 10000)) {
client.println("Hello TCP Server");
while (client.connected()) {
if (client.available()) {
String resp = client.readString();
Serial.println(resp);
}
}
} else { Serial.println("Connection failed"); }
Connected to server
Server response: ACK received
Prevention
Check return value of connect(). Set a timeout (3rd parameter). Verify server is reachable. Check firewall rules. Ensure port is correct.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro