I know this error is infuriating—you're just trying to edit a config file, and suddenly Windows won't accept it because a line is "too long." The exact code is 0X00000865, which maps to NERR_LineTooLong. It's old-school, but it still bites people on modern Windows 10 and 11 systems, especially when setting up legacy network mappings or custom LMHOSTS files.
The Fix: Split That Line
The core problem is simple: Windows (and older LAN Manager–based services) enforce a 256-character limit per line in certain configuration files, like LMHOSTS or some registry string values that are read line-by-line. If you try to paste a long UNC path, a complex domain entry, or a multi-parameter setting all on one line, you'll hit this wall.
Here's the fix—use the backslash continuation character to break the line. Windows will treat the backslash-newline sequence as a single logical line but without hitting the 256-char limit.
- Open the file in Notepad (or any plain-text editor). Do not use WordPad or Word—they add hidden formatting.
- Find the offending line. Count characters if you need to—the limit is 256. Anything over triggers the error.
- Insert a backslash
\right before the 256th character (or at a natural break like a space or comma), then press Enter immediately. No spaces after the backslash. - Continue the rest of the line on the new line. Keep doing this until the line fits within 256 characters per segment.
Example: Before (line too long):
192.168.1.100 SERVER-01 #PRE #DOM:MYDOMAIN #Special_App_Config_For_Backup_And_Replication_With_Long_Description_That_Easily_Exceeds_256_Characters
After (split with continuation):
192.168.1.100 SERVER-01 #PRE #DOM:MYDOMAIN \
#Special_App_Config_For_Backup_And_Replication_With_Long_Description_\
That_Easily_Exceeds_256_Characters
Save the file. The error should vanish.
Why This Works
The 256-character limit comes from the original LAN Manager network stack, a legacy from the early '90s. Microsoft kept it for backward compatibility in LMHOSTS, NBTSTAT, and some NetAPI calls. The backslash continuation is actually a documented feature in the LMHOSTS file format, but most people forget about it. It allows you to logically join lines without the physical character limit. Skipping this trick means you'll keep hitting the error.
Also, this error pops up most commonly when you manually edit C:\Windows\System32\drivers\etc\lmhosts and add a long entry for a remote server with multiple tags (#PRE, #DOM, #INCLUDE). I've seen it dozens of times in corporate environments where admins paste a long UNC path from a spreadsheet.
Less Common Variations
This error isn't limited to LMHOSTS. Here are other places where NERR_LineTooLong shows up:
- Registry string values – Specifically under
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\ParametersorHKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters. If you set a multi-line REG_SZ or REG_MULTI_SZ value manually, a single line that exceeds 256 characters can throw this error when the service reads it. The fix here is to break the string into separate registry entries or use a script to split the value across multiple lines using theREG ADDcommand with caution—some services expect a single line. - Net use commands – Running
net usewith a very long share path (over 256 characters) can trigger this internally. The solution: map a drive letter to a shorter path, or use a symbolic link to shorten the path before mapping. - Third-party network config tools – Some older backup or replication software that reads/writes config files inherits this limit. Check the app's documentation for line continuation support—most don't have it, so you'll need to shorten the entry.
If the continuation trick doesn't work for a registry-based error, you're better off shortening the value. For example, instead of a long UNC path like \\very-long-server-name.domain.com\shared\folder\subfolder\deep\path, use a mapped drive or a DFS path.
Prevention
To avoid this error in the future, follow two rules:
- Keep config lines under 200 characters – That leaves a buffer. If you're adding comments or tags, put them on a separate line whenever possible.
- Use the backslash continuation habitually – Even if your line is under 256 characters, splitting it at logical boundaries (after a tag like #PRE or before a long description) makes the file more readable and prevents issues if you later add more text.
- Test in a VM first – If you're editing LMHOSTS or registry values for a critical server, test the change on a non-production machine. The error can cause network services to fail silently if the file is malformed.
That's it—three steps and you're done. This error trips up even experienced admins because the limit is obscure and the fix (continuation) is hidden in documentation from the Windows 3.11 days. You've got this.