SMTP error 101
Network is unreachable — an OS socket error, not an SMTP code.
Updated Jul 1, 2026
SMTP 101 is not an SMTP reply code — real SMTP replies are three digits from 2xx to 5xx. 101 is the operating-system socket error ENETUNREACH ("network is unreachable"): your machine could not find a route to the mail server before any connection was made. The fix lives in your local network config — routing, IPv6, the interface, or a wrong host/port.
Fix local routing, IPv6, or the network interface, and confirm the host and port are correct.
What it means
When a library like PHPMailer or Python's smtplib reports "101", it is passing through a Linux kernel error, not a message from a mail server. errno 101 is ENETUNREACH. Your code asked the kernel to open a TCP connection to the SMTP host, the routing-table lookup failed, and no packet ever left the machine — so the SMTP conversation never began. You usually see it wrapped as "Failed to connect to server: Network is unreachable (101)" or "OSError: [Errno 101] Network is unreachable".
Common causes
A missing default gateway, or broken routing to the provider's IP range. This is the literal meaning of the error.
The hostname resolves to an IPv6 (AAAA) address but your machine or ISP has no working IPv6 route. Common on cloud VMs.
A container or VM with a dead interface, missing route, or broken virtual network stack fails instantly.
A misspelled hostname or a non-existent IP routes nowhere.
How to fix it
- Confirm it is routing, not a block
Test the path directly from the sending machine. A genuine 101 fails immediately with "unreachable"; a hang-then-timeout or "connection refused" is a firewall/port problem (110/111), not this.
ping smtp.yourprovider.com nc -vz smtp.yourprovider.com 587 - Check your routing table and gateway
Confirm a default route exists and points to a live gateway — a missing or stale one is the most direct cause.
ip route # or: route -n - Fix IPv6 or force IPv4
If the host resolves to IPv6 but you have no IPv6 route, repair IPv6 connectivity or connect over an IPv4 address explicitly.
- Verify the host and port
Cross-check spelling and port against your provider's docs — a typo'd hostname resolves to nothing routable.
Common questions
Is 101 a real SMTP status code?
No. SMTP replies are three digits in the 2xx–5xx range. 101 is the OS errno ENETUNREACH, raised before any SMTP exchange happens.
What is the difference between 101 and 111?
101 (ENETUNREACH) means your machine had no route to send on. 111 (ECONNREFUSED) means the host was reachable and actively rejected the port. Different layers, different fixes.
Why does it happen on my server but not my laptop?
The two machines have different network config — often the server is missing a default gateway or a working IPv6 route that your laptop has.