This may be caused by the clock on your system being out of sync with the clock used for online activation.
Occasionally, a computer’s internal clock may drift out of sync.
To fix this on Windows, go to Settings -> Time & Language -> Date & Time and press the “Sync now” button
For macOS this can be fixed by just going to preferences and going to Date & Time while the system is connected to the internet.