pythongoogle-colaboratorytor

Connecting Tor in Google Colab


I try to make use of the following git (https://github.com/cubicbyte/reddit-account-generator) in my colab, whereas I am struggling with following Error:

How many accounts do you want to make? 1 2024-05-09 16:31:17 INFO Checking if tor is running... 2024-05-09 16:31:20 INFO Tor is running. Connecting to Tor... Traceback (most recent call last):   File "/usr/local/lib/python3.10/dist-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 "/content/reddit-account-generator/create_accounts.py", line 58, in <module>     proxy_manager = TorProxy(TOR_IP, TOR_PORT, TOR_PASSWORD, TOR_CONTROL_PORT, TOR_DELAY)   File "/content/reddit-account-generator/reddit_account_generator/proxies.py", line 58, in __init__     self.controller = Controller.from_port(port=self.control_port)   File "/usr/local/lib/python3.10/dist-packages/stem/control.py", line 1033, in from_port     control_port = stem.socket.ControlPort(address, port)   File "/usr/local/lib/python3.10/dist-packages/stem/socket.py", line 503, in __init__     self.connect()   File "/usr/local/lib/python3.10/dist-packages/stem/socket.py", line 172, in connect     self._socket = self._make_socket()   File "/usr/local/lib/python3.10/dist-packages/stem/socket.py", line 538, in _make_socket     raise stem.SocketError(exc) stem.SocketError: [Errno 111] Connection refused` 

I also tried to handle it with:

!sudo apt-get install tor
!sudo service tor start
!sudo service tor status 
* Starting tor daemon...
   ...done.
* tor is running

Which also yielded to Errno111.

Any advice?

I tried to connect my jupyternotebook in colab to Tor.


Solution

  • The error message stem.SocketError: [Errno 111] Connection refused indicates that the script is unable to establish a connection to the Tor control port. Ensure Tor is running on the Google Colab machine. You can check its status using !service tor status. If it's not running, start it with !sudo service tor start . Double-check the TOR_CONTROL_PORT value in the script. The default might be 9051, but verify it in your Tor configuration