Connection Issues
Connection Issues
Section titled “Connection Issues”This guide covers common connection problems and their solutions.
Connection Refused
Section titled “Connection Refused”Symptoms: Clients receive “Connection refused” error when connecting to the proxy.
Cause 1: Service Not Running
Section titled “Cause 1: Service Not Running”The Bifrost server process may not be running.
Diagnosis:
# Check if process is runningps aux | grep bifrost
# Check systemd servicesystemctl status bifrost-server
# Check Docker containerdocker ps -a | grep bifrostSolution:
# Start via systemdsudo systemctl start bifrost-server
# Start via Dockerdocker start bifrost-server
# Start manuallybifrost-server -c /etc/bifrost/config.yamlCause 2: Wrong Bind Address
Section titled “Cause 2: Wrong Bind Address”The server is bound to localhost only, preventing external connections.
Diagnosis:
# Check what address the server is listening onnetstat -tlnp | grep bifrostss -tlnp | grep bifrostSolution:
# Wrong: Only localhost can connectserver: http: listen: "127.0.0.1:7080"
# Correct: All interfacesserver: http: listen: ":7080"
# Correct: Specific interfaceserver: http: listen: "192.168.1.100:7080"Cause 3: Firewall Blocking
Section titled “Cause 3: Firewall Blocking”A firewall is blocking the proxy port.
Diagnosis:
# Linux: Check iptablessudo iptables -L -n | grep 7080
# Check UFW statussudo ufw status
# Check firewalld (RHEL/CentOS)sudo firewall-cmd --list-all
# Test port connectivitync -zv localhost 7080telnet localhost 7080Solution:
# UFW (Ubuntu/Debian)sudo ufw allow 7080/tcpsudo ufw allow 7180/tcp # SOCKS5sudo ufw allow 7082/tcp # API
# firewalld (RHEL/CentOS)sudo firewall-cmd --permanent --add-port=7080/tcpsudo firewall-cmd --reload
# iptablessudo iptables -A INPUT -p tcp --dport 7080 -j ACCEPTCause 4: Port Already in Use
Section titled “Cause 4: Port Already in Use”Another process is using the configured port.
Diagnosis:
# Find what's using the portlsof -i :7080netstat -tlnp | grep 7080ss -tlnp | grep 7080Solution:
Either stop the conflicting process or change Bifrost’s port:
server: http: listen: ":8080" # Use different portConnection Timeout
Section titled “Connection Timeout”Symptoms: Connections hang and eventually timeout without response.
Cause 1: Backend Unreachable
Section titled “Cause 1: Backend Unreachable”The configured backend cannot be reached.
Diagnosis:
# Check backend health via APIcurl http://localhost:7082/api/v1/backends
# Test a request through the proxycurl -x http://localhost:7080 https://example.com -v --max-time 10
# Test direct connectivity to backendcurl -v https://example.com --max-time 10Solution:
- Verify backend configuration is correct
- Check backend server is running
- Test network connectivity to backend
# For WireGuard backendsudo wg show
# For OpenVPN backendps aux | grep openvpntail -f /var/log/openvpn.log
# For upstream proxycurl -x http://upstream-proxy:3128 https://example.comCause 2: DNS Resolution Failure
Section titled “Cause 2: DNS Resolution Failure”The proxy cannot resolve domain names.
Diagnosis:
# Test DNS resolutionnslookup example.comdig example.com
# Test from within container (if using Docker)docker exec bifrost-server nslookup example.comSolution:
Ensure DNS servers are configured:
# For WireGuard backendbackends: - name: wg-vpn type: wireguard config: dns: - "1.1.1.1" - "8.8.8.8"Or configure system DNS:
# Linux: /etc/resolv.confnameserver 1.1.1.1nameserver 8.8.8.8Cause 3: Timeout Configuration Too Short
Section titled “Cause 3: Timeout Configuration Too Short”Default timeouts may be too short for your network conditions.
Solution:
Increase timeout values:
server: http: read_timeout: "120s" write_timeout: "120s" idle_timeout: "300s"
socks5: connect_timeout: "60s"Cause 4: Network Routing Issues
Section titled “Cause 4: Network Routing Issues”Traffic isn’t being routed correctly.
Diagnosis:
# Check routing tableip route shownetstat -rn
# Trace route to destinationtraceroute example.commtr example.comProxy Authentication Required (407)
Section titled “Proxy Authentication Required (407)”Symptoms: Browser shows authentication prompt or curl returns 407 error.
Cause 1: Missing or Invalid Credentials
Section titled “Cause 1: Missing or Invalid Credentials”Credentials are not being sent or are incorrect.
Diagnosis:
# Test with explicit credentialscurl -x http://user:password@localhost:7080 https://example.com -v
# Check for 407 responsecurl -x http://localhost:7080 https://example.com -v 2>&1 | grep 407Solution:
- Verify credentials are correct
- Ensure credentials are properly URL-encoded if they contain special characters
# URL encode special characters# password "p@ss:word!" becomes "p%40ss%3Aword%21"curl -x http://user:p%40ss%3Aword%21@localhost:7080 https://example.comCause 2: Authentication Misconfigured
Section titled “Cause 2: Authentication Misconfigured”The authentication backend is not properly configured.
Diagnosis:
# Check server logs for auth errorsjournalctl -u bifrost-server | grep -i auth
# Verify auth configurationbifrost-server validate -c config.yamlSolution:
Verify authentication configuration:
auth: mode: native native: users: - username: myuser password_hash: "$2a$12$..." # bcrypt hashGenerate password hash:
# Using htpasswdhtpasswd -nbBC 12 "" "mypassword" | cut -d: -f2
# Using Pythonpython3 -c "import bcrypt; print(bcrypt.hashpw(b'mypassword', bcrypt.gensalt(12)).decode())"Cause 3: Auth Header Not Forwarded
Section titled “Cause 3: Auth Header Not Forwarded”Some proxy chains strip authentication headers.
Solution:
If using an upstream proxy, ensure Proxy-Authorization header is preserved or use a different authentication method.
SSL/TLS Certificate Errors
Section titled “SSL/TLS Certificate Errors”Symptoms: SSL handshake failures, certificate verification errors.
Cause 1: Self-Signed Certificate
Section titled “Cause 1: Self-Signed Certificate”The upstream server uses a self-signed certificate.
Diagnosis:
# Check certificateopenssl s_client -connect example.com:443 -servername example.com
# Test with curlcurl -v https://example.com 2>&1 | grep -i certificateSolution:
For testing only (not recommended for production):
backends: - name: upstream type: http_proxy config: tls_skip_verify: true # Only for testing!For production, add the CA certificate:
backends: - name: upstream type: http_proxy config: ca_cert: "/path/to/ca.crt"Cause 2: Expired Certificate
Section titled “Cause 2: Expired Certificate”The server’s TLS certificate has expired.
Diagnosis:
# Check certificate expirationecho | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -datesSolution:
Renew the certificate on the target server or contact the server administrator.
Cause 3: Certificate Name Mismatch
Section titled “Cause 3: Certificate Name Mismatch”The certificate doesn’t match the hostname being accessed.
Diagnosis:
# Check certificate subject and SANecho | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -text | grep -A1 "Subject Alternative Name"Connection Reset
Section titled “Connection Reset”Symptoms: Connection is abruptly terminated with “Connection reset by peer”.
Cause 1: Upstream Server Closed Connection
Section titled “Cause 1: Upstream Server Closed Connection”The upstream server terminated the connection.
Diagnosis:
# Check server logsjournalctl -u bifrost-server | grep -i reset
# Test with increased verbositycurl -x http://localhost:7080 https://example.com -v 2>&1 | grep -i resetSolution:
- Check if the upstream server has connection limits
- Verify the request is valid for the upstream server
- Check for rate limiting
Cause 2: Idle Connection Timeout
Section titled “Cause 2: Idle Connection Timeout”Long-lived connections are being terminated due to inactivity.
Solution:
Adjust idle timeout settings:
server: http: idle_timeout: "300s" # 5 minutesCause 3: MTU Issues
Section titled “Cause 3: MTU Issues”Network path MTU is causing packet fragmentation.
Diagnosis:
# Test with different packet sizesping -M do -s 1400 example.comping -M do -s 1200 example.comSolution:
Reduce MTU in tunnel configuration:
backends: - name: wg-vpn type: wireguard config: mtu: 1280 # Conservative valueSOCKS5 Connection Issues
Section titled “SOCKS5 Connection Issues”Symptoms: SOCKS5 proxy connections fail or timeout.
Cause 1: Wrong Protocol
Section titled “Cause 1: Wrong Protocol”Client is using HTTP proxy protocol instead of SOCKS5.
Diagnosis:
# Test SOCKS5 explicitlycurl --socks5 localhost:7180 https://example.com -v
# Test SOCKS5 with hostname resolution via proxycurl --socks5-hostname localhost:7180 https://example.com -vSolution:
Ensure client is configured to use SOCKS5 protocol:
# curlcurl --socks5 localhost:7180 https://example.com
# With authenticationcurl --socks5 user:pass@localhost:7180 https://example.comCause 2: SOCKS5 Listener Not Enabled
Section titled “Cause 2: SOCKS5 Listener Not Enabled”The SOCKS5 listener may not be configured.
Diagnosis:
# Check if SOCKS5 port is listeningnetstat -tlnp | grep 7180Solution:
Enable SOCKS5 listener:
server: socks5: enabled: true listen: ":7180"Connection Limit Reached
Section titled “Connection Limit Reached”Symptoms: New connections are rejected with “too many connections” error.
Cause: File Descriptor Limit
Section titled “Cause: File Descriptor Limit”The system has reached its file descriptor limit.
Diagnosis:
# Check current limitulimit -n
# Check open file descriptors for bifrostls /proc/$(pgrep bifrost-server)/fd | wc -l
# Check system-wide limitscat /proc/sys/fs/file-nrSolution:
Increase file descriptor limits:
# Temporary (current session)ulimit -n 65536
# Permanent: /etc/security/limits.conf* soft nofile 65536* hard nofile 65536
# For systemd service: /etc/systemd/system/bifrost-server.service[Service]LimitNOFILE=65536Diagnostic Commands Summary
Section titled “Diagnostic Commands Summary”# Quick health checkcurl -s http://localhost:7082/api/v1/health | jq
# Connection statisticscurl -s http://localhost:7082/api/v1/stats | jq
# Backend statuscurl -s http://localhost:7082/api/v1/backends | jq
# Active requestscurl -s http://localhost:7082/api/v1/requests | jq
# Test proxy connectivitycurl -x http://localhost:7080 https://httpbin.org/ip -v
# Test SOCKS5 connectivitycurl --socks5 localhost:7180 https://httpbin.org/ip -v