DEV Community

Cover image for Still no internet? How to prevent premature timeouts in Ubuntu?
Ingo Steinke, web developer
Ingo Steinke, web developer Subscriber

Posted on • Edited on

Still no internet? How to prevent premature timeouts in Ubuntu?

I have contributed to open data by hunting "Funklöcher" ("radio holes", as network dead zones are called in Germany) with the Federal Network Agency's Breitbandmessung network measurement tool, only to discover that "not no internet" still does not guarantee any usable connection. Similarly, there are some cheap router devices that popular ISPs send as a default, that work well enough for the majority of Windows, MacBooks, and iPhones, and everyone else should pay to rent or buy a FritzBox router. This has happened with various budget smartphones and older Lenovo laptops, but also my professional Linux laptop that rarely makes any trouble.

Internet connections that don't send data

But what's happening? Latency problems probably cause this kind of issues when there is a good, or at least sufficient, internet connection that some devices can use without issues, but some can't.

I gathered a lot of log files using a Linux laptop and a Huawei phone on a Vodafone network, but that's outdated now, and Vodafone support didn't think it was useful. Later I experienced similar problems with another Linux laptop in an O2 network. After replacing their router with a used FritzBox (many second-hand 1&1 routers can be reconfigured for any other popular ISP) the problems disappeared at home and I never had any similar problems in any professional workplace.

Travelling around the country in Deutsche Bahn trains and working from my dad's place in an old suburban house connected to an average Telekom network, I remembered my timeouts that became critical when I failed to reach GitHub and my own remote ssh server!

Increasing Ubuntu network timeouts and retries

Checking various sources, I learned that Ubuntu Linux networking did have some special problems, most of which seemed to have disappeared after an upgrade to the latest release at the time of writing. Those posts are usually five to ten years old. But one option still works in Ubuntu 22.04 in 2024: increasing the network timeouts and retries.

We can change the settings ad hoc using the sysctl interface. Tweaking net.ipv4 requires root privileges on my system, so I tried

  • sudo sysctl net.ipv4.tcp_fin_timeout=180 to increase the timeout to 3 minutes (3x the default 60 seconds)
  • sudo sysctl net.ipv4.tcp_synack_retries=8 to increase passive FTP retries above the default 5 times

A quick check before and after the settings looked good: GitHub, GMX (a popular German email provider), and several other servers notorious for latency problems with my Ubuntu machine on a train or with cheap routers, ran into timeouts before tweaking, but I could reach all of them almost immediately when trying again afterwards, at least in Google Chrome. Maybe the problem is worse in combination with Vivaldi, or my browser has cached the outdated network settings. 🤔

To persist these settings, I add the corresponding lines to my /etc/sysctl.conf configuration file:

# prevent timeouts when communicating with latent routers
# override default 60s timeout:
net.ipv4.tcp_fin_timeout=180

# override default 5 passive ftp retries
net.ipv4.tcp_synack_retries=8
Enter fullscreen mode Exit fullscreen mode

That's it!

I'll see and verify my solution. 👀

  • ☑️ using my dad's Telekom router ☎️: maybe less critical than before❓
  • 🧊 in a Deutsche Bahn train ("WiFi on ICE" 🧊)
  • ☑️ using the default O2 and Vodafone routers 🫧
  • ◻ using public cafés and bars ☕🍹

I still find it hard to tell. Between edge cases like "I can never connect to GitHub" and "I can always use every part of GitHub without any delay" lies reality and its perceived improvements and placebo effects unless I start measuring and gathering actual data, which I should also have done before tweaking my network. But here is an intermediate conclusion: I still had issues with the Telekom router net and always have occasional problems on a train, no matter which machine I use. Github gave me the most and the most critical timeouts when trying to work anywhere outside the big cities.

Update a few months later: Networking connections are still my laptop's only weakness. I have an open support ticket and send diagnostic data to my manufacturer, investigating at least two different problems. Disabling the docker service did not help.

  • weak network reception
    • erratic, hard to reproduce
    • ◻ TODO: inspect both network card antennas
  • connected, but no internet access
    • ◻ TODO: inspect networking details

I don't want to spend hours or days diagnosing networking issues. I already did when a cheap Android phone failed to connect to a Vodafone home station router reliably. I wasted so much time gathering connection details, sending them to support agents, and posting them to public forums, only to find out that

  • nobody cared
  • the cheap phone's chipset was known for several other bugs
  • a similar issue with the default O2 router was resolved by replacing it with a Fritz!Box that I got second-hand from a neighbor.

Installing another operating system (Linux Mint, Microsoft Windows) on the same machine might tell me more. There is an Ubuntu distribution update coming up.

I just want things to work, but I'd also like to know why they don't, to prevent similar errors in the future.

Update: thoughts and observations

  • Latency could be an issue, but it only seemed to amplify more severe issues.
  • Hardware could have been an issue, and it's worth checking. In my case, the network card and its antennas are not faulty, and I should not worry that they are inside a metal case, which is also true for Apple MacBook laptops.
  • Connection problems don't occur in all Wi-Fi networks. I suspect, but can't verify, configuration differences:
    • frequency bands (2.4 and/or 5 GHz)
    • IPv6 vs. only IPv4 support
  • Problems can get worse over time. Again, I can only suspect, but I see that

    • Docker creates more and more bridge networks that are never deleted automatically.
  • Upgrading a Linux distribution (dist-upgrade) is "never a good idea," and a fresh install should always be prepared; at least, that's what my laptop manufacturer's tech support told me.

  • Do other Linux distributions have the same problems with Docker? A Mint live system booted from a USB stick ran fine, but it had no Docker installed yet. And it's hard to tell when problems don't occur after installing Docker and running the first container setup.

Further reading

Discussion

Maybe you're a network expert or you had similar latency issues with your Ubuntu machine? What are your experiences and suggestions? Which tools and metrics do you use to measure network quality?

Top comments (1)