Whether you use SharePoint Online Management Shell to run the PowerShell?
Whether you have a proxy?
Please check the firewall is off and the network works well.
If you have an account secured with MFA, when using PnP PowerShell you have to use the weblogin option which shows a popup to support MFA.
Please use the below PnP powershell command:
Connect-PnPOnline -Url "https://contoso.sharepoint.com" -UseWebLogin
OR
Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive
Solution: Set up PowerShell proxy
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.