Linux errno 40 ELOOP Too Many Symbolic Links — What It Means & How to Fix It
About Linux errno 40 ELOOP Too Many Symbolic Links
Fix Linux errno 40 ELOOP when a circular symbolic link chain prevents file access by exceeding the maximum symlink traversal depth. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: ELOOP (errno 40) occurs when the kernel follows more than 40 symbolic links while resolving a path. This typically means two or more symlinks point to each other creating an infinite loop. The kernel's MAXSYMLINKS limit (40 on Linux) prevents infinite loops from hanging the system. The error can also occur with overly deep symlink chains that are not circular but exceed the limit. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Circular symbolic links: A -> B -> A creating an infinite loop. Package installation or configuration script creating incorrect symlinks. Manual symlink creation error pointing a link to itself or its parent. Deep symlink chains where many links resolve through other links exceeding 40 hops. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Identify the circular link: ls -la /path/to/symlink to see where it points. Use namei to trace the full resolution chain: namei -l /path/to/file to see each hop. Remove the circular symlink: rm /path/to/bad-symlink and recreate it pointing to the correct target. For deep chains, replace intermediate symlinks with direct links to the final target. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
What is the symlink limit?
Linux allows following up to 40 symbolic links in a single path resolution (MAXSYMLINKS = 40). This is a kernel constant designed to prevent infinite loops. Most legitimate paths resolve in fewer than 5 hops.
Overview
Fix Linux errno 40 ELOOP when a circular symbolic link chain prevents file access by exceeding the maximum symlink traversal depth.
Key Details
- ELOOP (errno 40) occurs when the kernel follows more than 40 symbolic links while resolving a path
- This typically means two or more symlinks point to each other creating an infinite loop
- The kernel's MAXSYMLINKS limit (40 on Linux) prevents infinite loops from hanging the system
- The error can also occur with overly deep symlink chains that are not circular but exceed the limit
Common Causes
- Circular symbolic links: A -> B -> A creating an infinite loop
- Package installation or configuration script creating incorrect symlinks
- Manual symlink creation error pointing a link to itself or its parent
- Deep symlink chains where many links resolve through other links exceeding 40 hops
Steps
- 1Identify the circular link: ls -la /path/to/symlink to see where it points
- 2Use namei to trace the full resolution chain: namei -l /path/to/file to see each hop
- 3Remove the circular symlink: rm /path/to/bad-symlink and recreate it pointing to the correct target
- 4For deep chains, replace intermediate symlinks with direct links to the final target