Hello there gopalv82,
We understand that you're unable to sign into iCloud on your Mac, but can online. Let's see how we can help with this.
Are you seeing that you're able to sign into your Apple ID on your Mac, or does this appear when signing into your Apple ID outside of just the iCloud section of your Apple ID in System Preferences?
Just so we're on the same page, do you use the steps of the following resource to sign into iCloud on your Mac?
Set up iCloud on your Mac
If those are the steps that you use, but still see this same message, let's try setting up another user on your account to test and see if you can sign in there. If you need assistance with setting up another user on your Mac, check out the steps here:
Set up users, guests, and groups on Mac
If you're still unable to sign in with a test user account, let's try connecting to a different network to see if that's what is preventing this from occurring.
We look forward to hearing back from you.
Have a great day!