The links are mostly for devices, but see if anything here helps.
https://www.imyfone.com/ios-data-erase/9-tips-to-fix-there-was-an-error-connecting-to-the-apple-id-server/
https://appletoolbox.com/error-connecting-apple-id-verification-failed-how-to-fix/
https://macreports.com/verification-failed-there-was-an-error-connecting-to-the-apple-id-server-fix/
https://appuals.com/fix-verification-failed-there-was-an-error-connecting-to-apple-id-server/
https://errorcodespro.com/there-was-an-error-connecting-to-the-apple-id-server/
https://search.yahoo.com/search?ei=utf-8&fr=aaplw&p=Verification+Failed%22+There+was+an+error+connecting+to+the+Apple+ID+server
Are you running any anti - virus programs? Using a VPN?
Try setting up another admin user account in System Preferences/Users & Groups to see if the same problem continues. Also try the Safe Mode.
Isolating an issue by using another user account
Safe Mode - About.
If it works in the Safe Mode, try running this program when booted normally and then copy and paste the output in a reply. The program was created by Etresoft, a frequent contributor. Please use copy and paste as screen shots can be hard to read. Click “Share Report” button in the toolbar, select “Copy to Clipboard” and then paste into a reply. This will show what is running on your computer. No personal information is shown. If the log won’t post, try posting it in Pastebin and provide a link in a reply. After pasting the report in a PasteBin page, go to the top of the page, and copy the address in the URL bar. Paste that in a new reply. Pastebin.
Etrecheck – System Information.
Web site version if required. https://etrecheck.com