Python: Stem ControlPort for tor connection refused

14 Views Asked by At

I am trying to use the tor controlPort 9051 through stem python library but I'm getting this error which I'm unable to resolve.

Traceback (most recent call last):
  File "/home/stark/.local/lib/python3.10/site-packages/stem/socket.py", line 535, in _make_socket
    control_socket.connect((self.address, self.port))
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/stark/tor-code/sample.py", line 3, in <module>
    with Controller.from_port(port = 9051) as controller:
  File "/home/stark/.local/lib/python3.10/site-packages/stem/control.py", line 1033, in from_port
    control_port = stem.socket.ControlPort(address, port)
  File "/home/stark/.local/lib/python3.10/site-packages/stem/socket.py", line 503, in __init__
    self.connect()
  File "/home/stark/.local/lib/python3.10/site-packages/stem/socket.py", line 172, in connect
    self._socket = self._make_socket()
  File "/home/stark/.local/lib/python3.10/site-packages/stem/socket.py", line 538, in _make_socket
    raise stem.SocketError(exc)
stem.SocketError: [Errno 111] Connection refused

I want to use stem to create a variable length tor circuit

0

There are 0 best solutions below