Skip to main content
ertius.org

`socat` to the rescue

I wanted to quickly forward traffic from a real network to something I'd bound to just localhost, and thus the correct incantation was:

root@somehost:~# socat tcp6-l:443,fork,reuseaddr,bind="[2001:DB8::1]" tcp4:127.0.0.1:443
2025/10/15 18:38:29 socat[31525] E read(6, 0x56024a25b000, 8192): Connection reset by peer
2025/10/15 18:38:35 socat[31526] E read(6, 0x56024a25b000, 8192): Connection reset by peer

My first try was more amusing, however:

root@somehost:~# socat tcp6-l:443,fork,reuseaddr,bind="[2001:DB8::1]" tcp:127.0.0.1:443
2025/10/15 18:37:44 socat[31523] W getaddrinfo("127.0.0.1", "443", {0x20,0,1,6}, {}): Address family for hostname not supported
2025/10/15 18:37:44 socat[31523] E _xioopen_ipapp_prepare(node="127.0.0.1", service="443", pf=0, ...): Address family for hostname not supported

the listening socket! And so this failed because it tried to find a It turns out that the tcp forwarding target inherits the protocol of way to ipv6 to 127.0.0.1.