Solved localhost vs. 127.0.0.1 with Microsoft’s sshd


Baeolophus

Active member
Member
Local time
5:10 AM
Posts
111
OS
macOS Sequoia
When I install Microsoft’s sshd (Settings → System → Optional features), I can make ssh connections to that host. So far, so good!

I would like to empty a command like
Bash:
ssh user@windowshost -L 15900:localhost:5900
. This is supposed to allow me to make a VNC connection on Port 15900 on the host from where the ssh connection originates, with the ssh connection forwarding that VNC traffic to Port 5900 on the host being connected to (windowshost), which is localhost to itself. This does not work. What does work is:
Bash:
ssh user@windowshost -L 15900:127.0.0.1:5900
It‘s as though the Windows shell does not understand “localhost.”

What is going on?
 
Windows Build/Version
26100.4349

My Computer

System One

  • OS
    macOS Sequoia
    Computer type
    Laptop
    Manufacturer/Model
    Apple
    CPU
    M1 Max Apple Silicon
    Memory
    32 GB
Just as a base test, can you ping localhost?
 

My Computer

System One

  • OS
    Windows 11 Pro 24H2
    Computer type
    Laptop
    Manufacturer/Model
    HP
    CPU
    Intel Ultra 7 155H
    Memory
    16gb
    Graphics Card(s)
    Intel Arc integrated
    Hard Drives
    SSD
Here’s what it looks like:

Screenshot 2025-07-03 at 10.21.47 AM.webp
In a shell made accessible via ssh, ping to 127.0.0.1 and localhost both work. However, whatever evaluates the
Bash:
-L local_socket:host:hostport
argument to my local bash shell ssh command on the remote host, which is a Windows 11 PC, does not know what to do, if host is “localhost.”
 

My Computer

System One

  • OS
    macOS Sequoia
    Computer type
    Laptop
    Manufacturer/Model
    Apple
    CPU
    M1 Max Apple Silicon
    Memory
    32 GB

My Computer

System One

  • OS
    Windows 11 Pro 26100.4351
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Built
    CPU
    Ryzen 5 5600G
    Motherboard
    ASUS X470 Prime Pro
    Memory
    32GB
    Monitor(s) Displays
    Alienware 2518HF
    Screen Resolution
    1920 x 1080
    Hard Drives
    Boot: NVME WDC WDS500G; ASUS M.2 Riser card with 3 additional NVME drives
    Various Internal SDD (Samsung and WDC) and HDD drives mostly Western Digital
    PSU
    Seasonic Focus Gold 650W
    Case
    Corsair 200R
    Cooling
    Noctua PWM fans x 3
    Keyboard
    Corsair K60 SE Pro
    Mouse
    Corsair Dark Core RGB Pro SE
    Internet Speed
    500/500
    Browser
    MS Edge
    Antivirus
    Malwarebytes Premium
For your PC, localhost is returned as a IPv6 address [::1]

Your options would be:
- Disable IPv6 on the network adapter's properties, if you don't need IPv6​
- Figure out how to configure IPv6 port forwarding​
- Use the 127.0.0.1 address to force IPv4 mode​
 

My Computer

System One

  • OS
    Windows 7
For your PC, localhost is returned as a IPv6 address [::1]
That’s the answer! How do I turn off IPv6 on a Windows machine?
 

My Computer

System One

  • OS
    macOS Sequoia
    Computer type
    Laptop
    Manufacturer/Model
    Apple
    CPU
    M1 Max Apple Silicon
    Memory
    32 GB

I normally set mine to 0x20, to prefer IPv4 without turning off v6.
 

My Computer

System One

  • OS
    Windows 11 Pro 24H2 [rev. 4349]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender

Latest Support Threads

Back
Top Bottom