The Pokémon Global Link is currently undergoing maintenance. If you try to use it, it will fail.
The maintenance started at midnight November 10 2017, and it will last until midnight 17 November 2017 (UTC). The Pokémon Company International has taken it offline to update it for the official release of Pokémon Ultra Sun and Pokémon Ultra Moon.
It seems that after the update it will work with both Pokémon Ultra Sun and Pokémon Ultra Moon, as well as with Pokémon Sun and Pokémon Moon. Right now the Global Link features won't work for either Pokémon Sun and Pokémon Moon, this includes Game Sync as well as Rating Battles.
After the maintenance is done, the new games will officially be released, in the meantime be sure to stay offline or else you will more than likely get banned like last year. Official information:
Source: https://3ds.pokemon-gl.com