首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Stem正在产生“无法连接到端口9051”错误。

Stem正在产生“无法连接到端口9051”错误。
EN

Stack Overflow用户
提问于 2016-02-29 12:40:35
回答 1查看 5.2K关注 0票数 5

我尝试了的例子:

代码语言:javascript
复制
import getpass
import sys

import stem
import stem.connection

from stem.control import Controller

if __name__ == '__main__':
  try:
    controller = Controller.from_port()
  except stem.SocketError as exc:
    print("Unable to connect to tor on port 9051: %s" % exc)
    sys.exit(1)

  try:
    controller.authenticate()
  except stem.connection.MissingPassword:
    pw = getpass.getpass("Controller password: ")

    try:
      controller.authenticate(password = pw)
    except stem.connection.PasswordAuthFailed:
      print("Unable to authenticate, password is incorrect")
      sys.exit(1)
  except stem.connection.AuthenticationFailure as exc:
    print("Unable to authenticate: %s" % exc)
    sys.exit(1)

  print("Tor is running version %s" % controller.get_version())
  controller.close()

去检查Tor的控制器是怎么工作的。但这给了我一个错误:

无法连接到端口9051 (Errno 111连接被拒绝)

我已经在/etc/tor/中的torrc文件中将ControlPort设置为9051,但是仍然会收到相同的错误。有人能帮忙吗?(我在VirtualBox上使用Ubuntu14.04)

编辑:在终端上运行tor -controlport 9051也会出现错误:

代码语言:javascript
复制
Feb 29 17:50:17.842 [notice] Tor v0.2.4.27 (git-412e3f7dc9c6c01a) running on Linux with Libevent 2.0.21-stable and OpenSSL 1.0.1f.
Feb 29 17:50:17.842 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Feb 29 17:50:17.842 [notice] Read configuration file "/etc/tor/torrc".
Feb 29 17:50:17.854 [notice] Opening Socks listener on 127.0.0.1:9050
Feb 29 17:50:17.854 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Feb 29 17:50:17.854 [notice] Opening Control listener on 127.0.0.1:9051
Feb 29 17:50:17.854 [notice] Closing partially-constructed Control listener on 127.0.0.1:9051
Feb 29 17:50:17.854 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Feb 29 17:50:17.854 [err] Reading config failed--see warnings above.

但当我跑

ps

没有正在运行tor的实例。编辑2:我尝试了命令sudo killall tor,然后用sudo /etc/init.d/tor status检查了它,现在它产生了一个身份验证错误:

代码语言:javascript
复制
 File "circuitPage.py", line 82, in printCircuitInfo
    controller.authenticate()
  File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 991, in authenticate
    stem.connection.authenticate(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/stem/connection.py", line 520, in authenticate
    raise AuthenticationFailure('socket connection failed (%s)' % exc)
stem.connection.AuthenticationFailure: socket connection failed ([Errno 111] Connection refused)
EN

回答 1

Stack Overflow用户

发布于 2018-11-05 15:26:50

ControlPort 9051配置文件中找到/etc/tor/torrc,然后取消对行的注释。

然后通过以下方式复位:

sudo service tor restart

现在您可以连接到端口9051。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35699833

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档