Use socket instead of env to get hostname