Why an Overloaded /etc/hosts File Can Stall Spring Boot Startup and How to Fix It
A single overly long line in /etc/hosts caused Spring Boot to hang while fetching Apollo configuration on CentOS 6, and splitting the line into shorter entries resolved the issue, highlighting a subtle hosts‑file limitation in older Linux kernels.
Problem Environment
System: CentOS 6.9 (kernel 2.6.32-696.16.1.el6.x86_64)
Java: 1.8.0_151
Apollo: 1.4.0
Framework: Spring Boot
Issue
After starting the service, it remains stuck at the step where it should pull configuration from Apollo, never completing the fetch.
2019-11-20 21:06:47.884 [main] INFO c.c.f.f.i.p.DefaultApplicationProvider - App ID is set to xdm-test by app.id property from /META-INF/app.properties
2019-11-20 21:06:47.886 [main] INFO c.c.f.f.i.p.DefaultServerProvider - Loading /opt/settings/server.properties
2019-11-20 21:06:47.886 [main] INFO c.c.f.f.i.p.DefaultServerProvider - Environment is set to [PRO] by property 'env' in server.properties.Investigation
Apollo itself works; manual requests can retrieve the configuration.
The same code runs fine in a VPC environment.
Changing Tomcat startup parameters to use /dev/urandom had no effect.
Network connectivity is fine; manual requests succeed.
Using tcpdump showed no outbound request from the application to Apollo.
Root Cause
The /etc/hosts file contained a single line mapping one IP address to 45 domain names, which made the hosts file malformed and caused the system resolver to ignore it.
192.168.108.108 a1.com a2.com a3.com a4.com a5.com a6.com a7.com a8.com a9.com a10.com a11.com a12.com a13.com a14.com a15.com a16.com a17.com a18.com a19.com a20.com a21.com a22.com a23.com a24.com a25.com a26.com a27.com a28.com a29.com a30.com a31.com a32.com a33.com a34.com a35.com a36.comSolution
Split the long line into two shorter lines and restart the service.
192.168.108.108 a1.com a2.com a3.com a4.com a5.com a6.com a7.com a8.com a9.com a10.com a11.com a12.com a13.com a14.com a15.com a16.com a17.com a18.com
192.168.108.108 a19.com a20.com a21.com a22.com a23.com a24.com a25.com a26.com a27.com a28.com a29.com a30.com a31.com a32.com a33.com a34.com a35.com a36.comReflection
The problem only appeared on CentOS 6.x; the same hosts configuration works on CentOS 7, indicating that the issue was fixed in later kernel versions.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
