InfluxDBClient initialize with localhost takes longer time to query than initialize with 127.0.0.1, about 2 seconds

We notice that if initialize InfluxDBClient with host http://localhost, it will take longer time to query than initialize InfluxDBClient with host http://127.0.0.1, any suggestion or solution?