Fix localhost checking in FileHandler. Raised in #21970.