This issue is specific to the Kaggle environment's network configuration, which is why it might work on Google Colab but not Kaggle.
The most common reason for this on kaggle is that internet access is not enabled for the notebook, To fix this, locate the Internet toggle switch and make sure it is turned ON. You might need to accept a disclaimer.