Python - OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

0

I'm at a loss therefore posting here. I'm getting the error in the title when trying to make an http/https web request through python from t-sql from a server (vm) on windows core. I have read here in other threads that could be a number of things like firewall related, non admin accounts cannot bind to lower ports and have not made any progress thus far. The sys admin I've been working with has assured me there is no firewall on the host server which could be causing this error or blocking python specifically. I was able to reach a different rest API via SSIS/C# script task/sql agent job using the same domain account without any issues.

Sample stripped version of code:

execute sp_execute_external_script
@language = N'Python',
@script = N'
import requests

r = requests.get("https://www.google.com")
print(r.status_code)
'

Error:

Msg 39004, Level 16, State 20, Line 0
A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 0
An external script error occurred: 
C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\revoscalepy\functions\RxSummary.py:4: FutureWarning: The Panel class is removed from pandas. Accessing it from the top-level namespace will also be removed in the next version
  from pandas import DataFrame, Index, Panel

Error in execution.  Check the output for more information.
Traceback (most recent call last):
  File "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\urllib3\connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection
    raise err
  File "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\PYTHON_SERVICES\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection

Msg 39019, Level 16, State 2, Line 0
An external script error occurred: 
    sock.connect(sa)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

During handling of the above exception, another exception occurred:

Have tried the following with no success:

  1. Reconfigure the launchpad service with a domain admin account
  2. Added the domain acccount to local admin group (even though domain admins already part of the group)
  3. Added mssqllaunchpad as a local admin
  4. Disabled windows firewall and rules which may block the traffic

Can someone please point me in the direction of generally speaking what causes this error and possibly how to resolve for my specific situation?

python
sql-server
python-requests

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0