Fix localhost checking in FileHandler. Raised in #21970.
Merge 3.4

Fix localhost checking in FileHandler. Raised in #21970.