Python code in T-SQL environment gives "access a socket in a way forbidden by its access permissions" Error
Open the Windows Firewall and look for a rule called "Block network access for R local user accounts in SQL Server instance MSSQLSERVER" (assuming you have a default instance).  This Firewall rule blocks network access from SQL Server external scripts.  You can disable the rule if you want to allow network access.