简体   繁体   English

stem.SocketError: [Errno 111] 连接被拒绝

[英]stem.SocketError: [Errno 111] Connection refused

I am trying to deploy a flask application as a.onion site.我正在尝试将 flask 应用程序部署为 a.onion 站点。 I am using stem.我正在使用茎。 I have gone through a bunch of tutorials, but still, come up with this error:我已经阅读了很多教程,但仍然出现了这个错误:

stem.SocketError: [Errno 111] Connection refused stem.SocketError: [Errno 111] 连接被拒绝

I have configured torrc, and I have changed the password for Tor Hidden Services.我已经配置了 torrc,并且我已经更改了 Tor 隐藏服务的密码。 I have even tried adjusting the code order(to no avail.).我什至尝试调整代码顺序(无济于事。)。 Does anyone know what is wrong?有谁知道出了什么问题?

Here is the code(This is the original from a tutorial (I have tried it without my own stuff.)):这是代码(这是教程的原件(我已经尝试过没有自己的东西。)):

from stem.control import Controller
from flask import Flask

if __name__ == "__main__":

    app = Flask("example")
    port = 5000
    host = "127.0.0.1"
    hidden_svc_dir = "c:/temp/"

    @app.route('/')
    def index():
        return "<h1>Tor works!</h1>"
    print (" * Getting controller")
    controller = Controller.from_port(address="127.0.0.1", port=9151)
    try:
        controller.authenticate(password="my_password")
        controller.set_options([
            ("HiddenServiceDir", hidden_svc_dir),
            ("HiddenServicePort", "80 %s:%s" % (host, str(port)))
            ])
        svc_name = open(hidden_svc_dir + "/hostname", "r").read().strip()
        print (" * Created host: %s" % svc_name)
    except Exception as e:
        print (e)
    app.run()

You are using two different ports.您正在使用两个不同的端口。 Getting controller from 9151 and then later setting options for 5000. Try using same port in both places.从 9151 获取 controller,然后为 5000 设置选项。尝试在两个地方使用相同的端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM