Ubuntu Machine Can Login To Google But Not Github

5 min read

Troubleshooting network connectivity issues on Linux can feel like navigating a maze, especially when the symptoms are selective. This specific failure pattern—where major commercial sites load perfectly while developer platforms time out or refuse connections—points directly to specific layers of the network stack rather than a general internet outage. A particularly frustrating scenario arises when an Ubuntu machine can login to Google but not GitHub. Understanding why this discrepancy exists is the first step toward restoring your development workflow without resorting to a full system reinstall.

Understanding the Selective Connectivity Phenomenon

When you can access google.com but github.Here's the thing — com hangs on "Establishing connection" or returns a "Connection timed out" error, you are not dealing with a broken internet connection. You are dealing with a routing, DNS, MTU, or firewall filtering issue that affects specific IP ranges or protocols differently.

Google operates a massive, globally distributed Anycast network designed for maximum reachability, often traversing different peering agreements and transit paths than GitHub (which relies heavily on Microsoft Azure and Fastly infrastructure). If a router along your path has a corrupted BGP table, an MTU mismatch causing packet fragmentation drops, or a stateful firewall inspecting TLS Client Hellos differently for specific SNI values, one destination succeeds while the other fails. On Ubuntu specifically, the interplay between systemd-resolved, Netplan, UFW/iptables, and container runtimes like Docker creates unique failure vectors that do not exist on Windows or macOS.

Step 1: Isolate the Layer — DNS vs. TCP/IP

Before changing configuration files, determine exactly where the handshake breaks. Open a terminal and run a sequence of diagnostic commands to separate name resolution from transport connectivity.

Test DNS Resolution

dig github.com +short
dig @1.1.1.1 github.com +short

If the first command returns nothing or times out but the second (using Cloudflare DNS) returns IPs immediately, your local resolver (systemd-resolved or /etc/resolv.conf configuration) is the culprit. If both return IPs, DNS is healthy.

Test TCP Connectivity (Port 443)

nc -zv github.com 443
# or
telnet github.com 443
# or using nmap for more detail
nmap -p 443 github.com

If nc (netcat) hangs and eventually times out, the TCP SYN packet is leaving your machine but the SYN/ACK is not returning, or the SYN is being dropped en route. If it succeeds instantly ("Connection to github.com 443 port [tcp/https] succeeded!"), the network path is clear, and the issue lies higher up—likely in TLS negotiation, Git credential helpers, or SSH key agents.

Test ICMP (Ping)

ping -c 4 github.com

Note that many cloud providers rate-limit or block ICMP. A failed ping does not mean the host is down if TCP 443 works. Even so, if ping works but TCP 443 fails, you have a firewall or port-filtering issue.

Step 2: The MTU Mismatch — A Silent Killer on Ubuntu

One of the most common causes for "Google works, GitHub fails" on Linux is an MTU (Maximum Transmission Unit) mismatch, particularly common on VPNs, VPS instances (AWS EC2, DigitalOcean Droplets), VLANs, or PPPoE connections That alone is useful..

Standard Ethernet MTU is 1500 bytes. So google’s front-end servers often serve smaller initial payloads or handle Path MTU Discovery (PMTUD) more aggressively via ICMP "Packet Too Big" messages. If your tunnel interface (like tun0, wg0, docker0, or a VXLAN overlay) has an MTU of 1420 or 1450, but your physical interface (eth0, enp3s0) remains at 1500, large packets with the "Don't Fragment" (DF) bit set will be dropped silently by a router that cannot fragment them. GitHub’s TLS termination points may send larger certificates or OCSP stapling responses that exceed the tunnel MTU, causing the handshake to stall at Client Hello or Server Hello.

People argue about this. Here's where I land on it.

Diagnose MTU Issues Use tracepath (installed by default on Ubuntu) which performs PMTUD automatically:

tracepath -n github.com

Look for the line indicating pmtu. If it shows a value lower than 1500 (e.g., pmtu 1420), your path has a bottleneck.

Fix MTU Permanently via Netplan Edit your Netplan configuration (usually /etc/netplan/00-installer-config.yaml or 50-cloud-init.yaml):

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      mtu: 1420  # Set to the discovered PMTU value
      dhcp4: true

Apply with sudo netplan apply. If you are on a VPN, configure the MTU inside the VPN client config (e.g., mtu 1420 in WireGuard [Interface] section or OpenVPN tun-mtu 1420) And that's really what it comes down to..

Step 3: Docker and Container Network Conflicts

If you run Docker on Ubuntu, the docker0 bridge and overlay networks create iptables rules and virtual interfaces that frequently hijack traffic destined for specific subnets. In real terms, docker defaults to the 172. 17.0.That's why 0/16 subnet, but it also creates routes for 172. 18.0.And 0/16, 172. Think about it: 19. That said, 0. 0/16, etc. If GitHub’s IP ranges (which shift dynamically behind Fastly/Azure) happen to overlap with a Docker network subnet or if the DOCKER-USER chain drops packets due to a missing RETURN rule, connectivity breaks selectively.

Check for Conflicting Routes

ip route show | grep -E 'docker|172\.(1[6-9]|2[0-9]|3[0-1])\.'

Inspect Iptables Filter Table

sudo iptables -L -n -v | grep -i github
# Better: Watch the counters while curling
sudo watch -n 1 'iptables -L -n -v | grep -E "DOCKER|REJECT|DROP"'

The Fix: Ensure your Docker daemon uses a non-conflicting subnet in /etc/docker/daemon.json:

{
  "bip": "10.200.0.1/24",
  "fixed-cidr": "10.200.0.0/24"
}

Restart Docker (sudo systemctl restart docker). This moves the bridge out of the standard private ranges that cloud providers often use for their internal load balancers Worth keeping that in mind..

Step 4: systemd-resolved and Split DNS Issues

Ubuntu 20.Consider this: 04+ uses systemd-resolved as a stub resolver listening on 127. It implements "Split DNS" logic where different interfaces get different search domains and DNS servers. 0.com queries to the global DNS (via your physical interface) and internal.Worth adding: if you are on a corporate VPN (WireGuard, OpenConnect, Cisco AnyConnect), the VPN pushes a DNS server intended for internal resources. 0.53. Now, systemd-resolved should route github. corp to the VPN DNS.

New and Fresh

Recently Added

Related Territory

More on This Topic

Thank you for reading about Ubuntu Machine Can Login To Google But Not Github. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home