VPS stuck at HTTP request sent and HTTPS cannot establish handshake solution

How I encounter this wired MTU issue

I got this error when renting some VPS from yardvps.com photonvps.com onevps.cloud

Operating system that I use is Debian 10 unstable branch (IPv4/IPv6 dual stack) with following setup

cat /etc/resolv.conf
nameserver 94.140.14.14
nameserver 76.76.2.2

cat /etc/sysctl.conf
net.ipv6.conf.all.accept_ra = 2
fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_mem = 25600 51200 102400
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1
net.ipv6.conf.all.autoconf = 1
net.ipv6.conf.all.accept_ra = 2
net.ipv6.ip_forward=1
net.ipv6.conf.all.proxy_ndp = 1
net.ipv6.route.max_size = 16384
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.default.accept_ra=2

uname -rms
Linux 5.10.0-8-amd64 x86_64

Error message

wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz -4
--2021-08-11 22:07:51--  http://mirrors.linuxeye.com/oneinstack-full.tar.gz
Resolving mirrors.linuxeye.com (mirrors.linuxeye.com)... 45.79.84.47
Connecting to mirrors.linuxeye.com (mirrors.linuxeye.com)|45.79.84.47|:80... connected.
HTTP request sent, awaiting response...

Solution

# Set MTU to 1400
ifconfig eth0 mtu 1400 up

Note MTU value may vary depends on VPS provider, you can try 1400, 1420, 1460, 1480

Docker solution

# Set MTU to 1280
ifconfig docker0 mtu 1280 up

# Add this into iptables
iptables -N DOCKER-USER
iptables -I DOCKER-USER -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

References

  1. https://blog.dachary.org/2013/12/10/wget-on-an-openstack-instance-hangs-try-lowering-the-mtu/
  2. https://www.linuxquestions.org/questions/linux-networking-3/pppoe-http-request-sent-awaiting-response-4175603545/
  3. https://discourse.drone.io/t/docker-mtu-problem/1207/11

Photo by Lina Trochez on Unsplash