Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

connect to host … : Unknown error for WSAEHOSTUNREACH / WSAENETUNREACH (no errno mapping)

Open Beginner friendly
#2,482 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
networking

Research direction

Start in contrib/win32/win32compat/socketio.c at errno_from_WSAError(), where the issue identifies missing mappings for WSAEHOSTUNREACH and WSAENETUNREACH; check misc.c for the corresponding error strings. Run the relevant Windows connection tests, if available, and confirm unreachable hosts produce a meaningful error instead of “Unknown error.”

Written by the indexing model from the issue text.

Description

Summary

When the TCP connect fails because the host or network is unreachable (for example, Wi-Fi drops), ssh prints

ssh: connect to host 192.168.0.63 port 22: Unknown error

instead of a meaningful message. Tools that parse ssh's output to decide whether a failure is transient can't classify it. VS Code Remote-SSH, for example, treats it as a permanent error and stops reconnecting.

Steps to reproduce
  1. ssh -F NUL -o BatchMode=yes [email protected] (no route) → ssh: connect to host 240.0.0.1 port 22: Unknown error, instantly.
  2. Or, with Wi-Fi disconnected (netsh wlan disconnect), ssh <LAN host> → same Unknown error. .NET reports the same connect as SocketError.HostUnreachable (10065).
Expected

No route to host / Network is unreachable (or at least a message naming the Winsock error).

Actual

Unknown error.

Cause

contrib/win32/win32compat/socketio.c, errno_from_WSAError() maps only a handful of WSA codes. Everything else falls to

default:
    return wsaerrno - 10000;

So WSAEHOSTUNREACH (10065) becomes errno 65 and WSAENETUNREACH (10051) becomes 51. w32_strerror() in misc.c only has strings for EADDRINUSE..EWOULDBLOCK (100–140), so strerror_s returns "Unknown error" for those values.

Suggested fix: add explicit cases:

  • WSAENETDOWN → ENETDOWN
  • WSAENETUNREACH → ENETUNREACH
  • WSAEHOSTUNREACH → EHOSTUNREACH
  • WSAEADDRNOTAVAIL → EADDRNOTAVAIL

Optionally, use the POSIX/glibc wording in _sys_errlist_ext ("No route to host", "Network is unreachable"); the current "Host is unreachable" and "Network unreachable" differ from what other platforms print and from what scripts match.

Version
  • OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 (Windows 10 Pro 22H2 19045, built-in)
  • Same code in v10.4.0.0 (socketio.c unchanged).
Dominant language
No language data
Stars
8.3k
Forks
822
Avg merge
3d 2h
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/Win32-OpenSSH

All issues in PowerShell/Win32-OpenSSH

Similar issues

More Networking issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.