Skip to content

Instantly share code, notes, and snippets.

@tnm
Created November 12, 2025 23:41
Show Gist options
  • Select an option

  • Save tnm/054f1b7ab2a2f950a57c65bb38ba4a16 to your computer and use it in GitHub Desktop.

Select an option

Save tnm/054f1b7ab2a2f950a57c65bb38ba4a16 to your computer and use it in GitHub Desktop.
Confirm IPv6 binding issue causing 502 Bad Gateway in Cased CD

Confirm IPv6 Binding Issue and Test Fix

The Problem

The backend is listening on IPv6 only (:::8081), but nginx is trying to connect via IPv4.

Confirmation Tests

1. Confirm IPv6-only binding

# Check if backend responds on IPv4 loopback
curl -v --ipv4 http://127.0.0.1:8081/health

Expected: Connection refused or timeout

# Check if backend responds on IPv6 loopback
curl -v --ipv6 http://[::1]:8081/health

Expected: Should return "OK" βœ…

2. Confirm nginx can't reach it

# Test what nginx is doing
curl -v http://localhost:8080/api/v1/settings/audit

Expected: 502 Bad Gateway (current issue)

Quick Fix Test

Try forcing the backend to listen on IPv4:

Option A: Test with netcat (if available)

# Kill the current backend (it will restart)
pkill cased-backend

# Wait for restart, then check binding again
sleep 3
netstat -tlnp | grep 8081

Option B: Test if ::1 works from nginx

# Check if we can reach backend via IPv6 localhost
curl http://[::1]:8081/health

Expected: Should return "OK"

The Real Fix (if confirmed)

If IPv6 works ([::1]:8081) but IPv4 doesn't (127.0.0.1:8081), then we need to:

Either:

  1. Make backend bind to 0.0.0.0:8081 (IPv4) explicitly
  2. Make nginx use [::1]:8081 instead of localhost:8081
  3. Enable IPv6 in nginx resolver config

Quickest Workaround (For Testing)

If you want to test if this fixes it immediately:

# Inside the pod, try accessing via IPv6 through nginx
# (This won't work directly, but confirms the issue)

# Check if curl can reach via IPv4 vs IPv6
curl --ipv4 -I http://localhost:8081/health
curl --ipv6 -I http://localhost:8081/health

If IPv6 works and IPv4 doesn't, that's the smoking gun πŸ”«

Expected Results

  • ❌ curl --ipv4 http://127.0.0.1:8081/health fails
  • βœ… curl --ipv6 http://[::1]:8081/health works
  • ❌ curl http://localhost:8080/api/v1/settings/audit fails (502)

If all three match expectations above, the fix is confirmed and we should change the Go backend to bind explicitly to IPv4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment