Skip to content

[Bug]: netstat port watcher crashes on hosts without /proc/net/tcp6 (IPv6 disabled) #705

@YassineElbouchaibi

Description

@YassineElbouchaibi

Before submitting

  • I have searched existing issues to confirm this is not a duplicate
  • I am running the latest version of DevPod

What happened?

On a Linux host where IPv6 is disabled (RHEL 9 with no IPv6), launching an OpenVSCode IDE workspace via DevPod fails to forward any ports. The DevPod agent log shows a repeating error:

Error watching ports: open /proc/net/tcp6: no such file or directory

Tracing this through the code: pkg/netstat/watcher.go:findPorts() unconditionally calls TCP6Socks(), which propagates the resulting os.Open error from doNetstatosTCP6SocksTCP6SocksfindPortsrunOnce. Because findPorts returns nil, err on IPv6 failure, the IPv4 sockets it already successfully collected are discarded and no ports are forwarded at all.

Relevant code:

  • pkg/netstat/netstat_util.go:249-261doNetstat opens the proc file and returns any error verbatim, with no IsNotExist check
  • pkg/netstat/watcher.go:86-91findPorts aborts on the TCP6Socks error instead of falling back to the already-collected IPv4 results

The net effect is that the OpenVSCode server port (default 10800) never gets forwarded, and the IDE is unreachable from the client.

What did you expect to happen instead?

TCP6Socks (and UDP6Socks) should treat a missing /proc/net/tcp6 / /proc/net/udp6 as "no IPv6 sockets" and return an empty slice with a nil error. Port forwarding should continue to work for IPv4 sockets on IPv6-disabled hosts, and OpenVSCode should be reachable.

Suggested fix: in doNetstat (or in osTCP6Socks / osUDP6Socks), check errors.Is(err, fs.ErrNotExist) on the os.Open result and return nil, nil in that case.

Steps to reproduce

Real-world trigger (what I hit):

  1. Provision a RHEL 9 host with IPv6 disabled (so /proc/net/tcp6 does not exist)
  2. Configure DevPod with the Docker provider on that host
  3. devpod up <workspace> --ide openvscode
  4. Observe that the OpenVSCode server never becomes reachable and the agent log contains repeating Error watching ports: open /proc/net/tcp6: no such file or directory entries

Minimal standalone reproducer (runs on any macOS host or any Linux host with IPv6 disabled — both lack /proc/net/tcp6 and exercise the exact same code path; the pkg/netstat package has no //go:build linux constraint so it compiles on macOS as well):

git clone https://github.com/skevetter/devpod
cd devpod
cat > /tmp/devpod_ipv6_repro.go <<'REPRO'
package main

import (
	"fmt"
	"os"

	"github.com/skevetter/devpod/pkg/netstat"
)

func main() {
	if _, err := netstat.TCP6Socks(netstat.NoopFilter); err != nil {
		fmt.Fprintf(os.Stderr, "BUG REPRODUCED: TCP6Socks failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Println("OK")
}
REPRO
go run /tmp/devpod_ipv6_repro.go

Output with the bug present:

BUG REPRODUCED: TCP6Socks failed: open /proc/net/tcp6: no such file or directory
exit status 1

Output after the fix:

OK

Note: on a Linux host that has IPv6 enabled, the reproducer will print OK because /proc/net/tcp6 exists. To observe the failure, run it on macOS or on an IPv6-disabled Linux host.

devcontainer.json

Not applicable — the bug is in the port watcher and is independent of devcontainer config.

Error output / logs

Error watching ports: open /proc/net/tcp6: no such file or directory
Error watching ports: open /proc/net/tcp6: no such file or directory
Error watching ports: open /proc/net/tcp6: no such file or directory
# ... repeats every 3 seconds, no ports ever forwarded

How often does this happen?

Every time

Operating system

Linux

Linux distribution

RHEL 9

Architecture

AMD64

Desktop app or CLI?

CLI only

DevPod version

v0.19.0

DevPod provider

Docker

Provider version

latest

Anything else?

The bug also affects UDP6Socks, though it is not currently called from findPorts. The fix should cover both to prevent future regressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions