[GH-ISSUE #740] [BUG] Systemd Tor Proxy Environment Variable #472

Closed
opened 2026-02-25 20:35:50 +03:00 by kerem · 2 comments
Owner

Originally created by @MadcowOG on GitHub (May 1, 2022).
Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/740

I installed whoogle through the Aur. I wanted to proxy my whoogle connection through tor.
This is my systemd unit file:

[Unit]
Description=Whoogle
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=whoogle
WorkingDirectory=/opt/whoogle-search
EnvironmentFile=/etc/default/whoogle
Environment=WHOOGLE_PROXY_TYPE=$PROXY_TYPE
Environment=WHOOGLE_PROXY_LOC=$PROXY_LOC
ExecStart=/opt/whoogle-search/venv/bin/python -um app --host $BIND_ADDRESS --port $LISTEN_PORT
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=3
SyslogIdentifier=whoogle
ReadOnlyPaths=/
ReadWritePaths=/opt/whoogle-search

[Install]
WantedBy=multi-user.target

$PROXY_TYPE is socks5 and $PROXY_LOC is 127.0.0.1:9050 for my local tor address.

I get this error with the proxy environment variable enabled:

May 01 00:59:28 whoogle[21286]: ERROR:app:Exception on /search [GET]
May 01 00:59:28 whoogle[21286]: Traceback (most recent call last):
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connection.py", line 169, in _new_conn
May 01 00:59:28 whoogle[21286]:     conn = connection.create_connection(
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection
May 01 00:59:28 whoogle[21286]:     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
May 01 00:59:28 whoogle[21286]:   File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
May 01 00:59:28 whoogle[21286]:     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
May 01 00:59:28 whoogle[21286]: socket.gaierror: [Errno -2] Name or service not known
May 01 00:59:28 whoogle[21286]: During handling of the above exception, another exception occurred:
May 01 00:59:28 whoogle[21286]: Traceback (most recent call last):
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 696, in urlopen
May 01 00:59:28 whoogle[21286]:     self._prepare_proxy(conn)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 964, in _prepare_proxy
May 01 00:59:28 whoogle[21286]:     conn.connect()
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connection.py", line 353, in connect
May 01 00:59:28 whoogle[21286]:     conn = self._new_conn()
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connection.py", line 181, in _new_conn
May 01 00:59:28 whoogle[21286]:     raise NewConnectionError(
May 01 00:59:28 whoogle[21286]: urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fabbab202b0>: Failed to establish a new connection: [Errno -2] Name or service not known
May 01 00:59:28 whoogle[21286]: During handling of the above exception, another exception occurred:
May 01 00:59:28 whoogle[21286]: Traceback (most recent call last):
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/adapters.py", line 439, in send
May 01 00:59:28 whoogle[21286]:     resp = conn.urlopen(
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 755, in urlopen
May 01 00:59:28 whoogle[21286]:     retries = retries.increment(
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 574, in increment
May 01 00:59:28 whoogle[21286]:     raise MaxRetryError(_pool, url, error or ResponseError(cause))
May 01 00:59:28 whoogle[21286]: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /search?gbv=1&num=10&q=apples&safe=off (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fabbab202b0>: Failed to establish a new connection: [Errno -2] Name or service not known')))
May 01 00:59:28 whoogle[21286]: During handling of the above exception, another exception occurred:
May 01 00:59:28 whoogle[21286]: Traceback (most recent call last):
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 2446, in wsgi_app
May 01 00:59:28 whoogle[21286]:     response = self.full_dispatch_request()
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1951, in full_dispatch_request
May 01 00:59:28 whoogle[21286]:     rv = self.handle_user_exception(e)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1820, in handle_user_exception
May 01 00:59:28 whoogle[21286]:     reraise(exc_type, exc_value, tb)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/_compat.py", line 39, in reraise
May 01 00:59:28 whoogle[21286]:     raise value
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1949, in full_dispatch_request
May 01 00:59:28 whoogle[21286]:     rv = self.dispatch_request()
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1935, in dispatch_request
May 01 00:59:28 whoogle[21286]:     return self.view_functions[rule.endpoint](**req.view_args)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/app/routes.py", line 94, in decorated
May 01 00:59:28 whoogle[21286]:     return f(*args, **kwargs)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/app/routes.py", line 53, in decorated
May 01 00:59:28 whoogle[21286]:     return f(*args, **kwargs)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/app/routes.py", line 319, in search
May 01 00:59:28 whoogle[21286]:     response = search_util.generate_response()
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/app/utils/search.py", line 133, in generate_response
May 01 00:59:28 whoogle[21286]:     get_body = g.user_request.send(query=full_query,
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/app/request.py", line 305, in send
May 01 00:59:28 whoogle[21286]:     response = requests.get(
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/api.py", line 76, in get
May 01 00:59:28 whoogle[21286]:     return request('get', url, params=params, **kwargs)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/api.py", line 61, in request
May 01 00:59:28 whoogle[21286]:     return session.request(method=method, url=url, **kwargs)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/sessions.py", line 542, in request
May 01 00:59:28 whoogle[21286]:     resp = self.send(prep, **send_kwargs)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/sessions.py", line 655, in send
May 01 00:59:28 whoogle[21286]:     r = adapter.send(request, **kwargs)
May 01 00:59:28 whoogle[21286]:   File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/adapters.py", line 510, in send
May 01 00:59:28 whoogle[21286]:     raise ProxyError(e, request=request)
May 01 00:59:28 whoogle[21286]: requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /search?gbv=1&num=10&q=apples&safe=off (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fabbab202b0>: Failed to establish a new connection: [Errno -2] Name or service not known')))

And the webpage gives a 500 Internal Error upon searching.

I don't believe this is entirely related, but in the configuration on the homepage Tor is always unavailable, whether I've configured the proxy or not.
Am I setting this up wrong?
Thank you

Originally created by @MadcowOG on GitHub (May 1, 2022). Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/740 I installed whoogle through the [Aur](https://aur.archlinux.org/packages/whoogle). I wanted to proxy my whoogle connection through tor. This is my systemd unit file: ``` [Unit] Description=Whoogle After=network-online.target Wants=network-online.target [Service] Type=simple User=whoogle WorkingDirectory=/opt/whoogle-search EnvironmentFile=/etc/default/whoogle Environment=WHOOGLE_PROXY_TYPE=$PROXY_TYPE Environment=WHOOGLE_PROXY_LOC=$PROXY_LOC ExecStart=/opt/whoogle-search/venv/bin/python -um app --host $BIND_ADDRESS --port $LISTEN_PORT ExecReload=/bin/kill -HUP $MAINPID Restart=always RestartSec=3 SyslogIdentifier=whoogle ReadOnlyPaths=/ ReadWritePaths=/opt/whoogle-search [Install] WantedBy=multi-user.target ``` $PROXY_TYPE is socks5 and $PROXY_LOC is 127.0.0.1:9050 for my local tor address. I get this error with the proxy environment variable enabled: ``` May 01 00:59:28 whoogle[21286]: ERROR:app:Exception on /search [GET] May 01 00:59:28 whoogle[21286]: Traceback (most recent call last): May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connection.py", line 169, in _new_conn May 01 00:59:28 whoogle[21286]: conn = connection.create_connection( May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection May 01 00:59:28 whoogle[21286]: for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): May 01 00:59:28 whoogle[21286]: File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo May 01 00:59:28 whoogle[21286]: for res in _socket.getaddrinfo(host, port, family, type, proto, flags): May 01 00:59:28 whoogle[21286]: socket.gaierror: [Errno -2] Name or service not known May 01 00:59:28 whoogle[21286]: During handling of the above exception, another exception occurred: May 01 00:59:28 whoogle[21286]: Traceback (most recent call last): May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 696, in urlopen May 01 00:59:28 whoogle[21286]: self._prepare_proxy(conn) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 964, in _prepare_proxy May 01 00:59:28 whoogle[21286]: conn.connect() May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connection.py", line 353, in connect May 01 00:59:28 whoogle[21286]: conn = self._new_conn() May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connection.py", line 181, in _new_conn May 01 00:59:28 whoogle[21286]: raise NewConnectionError( May 01 00:59:28 whoogle[21286]: urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fabbab202b0>: Failed to establish a new connection: [Errno -2] Name or service not known May 01 00:59:28 whoogle[21286]: During handling of the above exception, another exception occurred: May 01 00:59:28 whoogle[21286]: Traceback (most recent call last): May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/adapters.py", line 439, in send May 01 00:59:28 whoogle[21286]: resp = conn.urlopen( May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 755, in urlopen May 01 00:59:28 whoogle[21286]: retries = retries.increment( May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 574, in increment May 01 00:59:28 whoogle[21286]: raise MaxRetryError(_pool, url, error or ResponseError(cause)) May 01 00:59:28 whoogle[21286]: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /search?gbv=1&num=10&q=apples&safe=off (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fabbab202b0>: Failed to establish a new connection: [Errno -2] Name or service not known'))) May 01 00:59:28 whoogle[21286]: During handling of the above exception, another exception occurred: May 01 00:59:28 whoogle[21286]: Traceback (most recent call last): May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 2446, in wsgi_app May 01 00:59:28 whoogle[21286]: response = self.full_dispatch_request() May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1951, in full_dispatch_request May 01 00:59:28 whoogle[21286]: rv = self.handle_user_exception(e) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1820, in handle_user_exception May 01 00:59:28 whoogle[21286]: reraise(exc_type, exc_value, tb) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/_compat.py", line 39, in reraise May 01 00:59:28 whoogle[21286]: raise value May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1949, in full_dispatch_request May 01 00:59:28 whoogle[21286]: rv = self.dispatch_request() May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/flask/app.py", line 1935, in dispatch_request May 01 00:59:28 whoogle[21286]: return self.view_functions[rule.endpoint](**req.view_args) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/app/routes.py", line 94, in decorated May 01 00:59:28 whoogle[21286]: return f(*args, **kwargs) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/app/routes.py", line 53, in decorated May 01 00:59:28 whoogle[21286]: return f(*args, **kwargs) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/app/routes.py", line 319, in search May 01 00:59:28 whoogle[21286]: response = search_util.generate_response() May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/app/utils/search.py", line 133, in generate_response May 01 00:59:28 whoogle[21286]: get_body = g.user_request.send(query=full_query, May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/app/request.py", line 305, in send May 01 00:59:28 whoogle[21286]: response = requests.get( May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/api.py", line 76, in get May 01 00:59:28 whoogle[21286]: return request('get', url, params=params, **kwargs) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/api.py", line 61, in request May 01 00:59:28 whoogle[21286]: return session.request(method=method, url=url, **kwargs) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/sessions.py", line 542, in request May 01 00:59:28 whoogle[21286]: resp = self.send(prep, **send_kwargs) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/sessions.py", line 655, in send May 01 00:59:28 whoogle[21286]: r = adapter.send(request, **kwargs) May 01 00:59:28 whoogle[21286]: File "/opt/whoogle-search/venv/lib/python3.10/site-packages/requests/adapters.py", line 510, in send May 01 00:59:28 whoogle[21286]: raise ProxyError(e, request=request) May 01 00:59:28 whoogle[21286]: requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /search?gbv=1&num=10&q=apples&safe=off (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fabbab202b0>: Failed to establish a new connection: [Errno -2] Name or service not known'))) ``` And the webpage gives a 500 Internal Error upon searching. I don't believe this is entirely related, but in the configuration on the homepage Tor is always unavailable, whether I've configured the proxy or not. Am I setting this up wrong? Thank you
kerem closed this issue 2026-02-25 20:35:50 +03:00
Author
Owner

@nakoo commented on GitHub (May 1, 2022):

WHOOGLE_PROXY_* isn't used for Tor connection. You need to set up Tor yourself. PKGBUILD doesn't have Tor dependency either. It's better to contact AUR maintainer.

<!-- gh-comment-id:1114360365 --> @nakoo commented on GitHub (May 1, 2022): `WHOOGLE_PROXY_*` isn't used for Tor connection. You need to set up Tor yourself. PKGBUILD doesn't have Tor dependency either. It's better to contact AUR maintainer.
Author
Owner

@MadcowOG commented on GitHub (May 2, 2022):

I already have tor enabled and started on my system, is there a reason that the tor option isn't available?

I will contact the maintainer.

<!-- gh-comment-id:1114560015 --> @MadcowOG commented on GitHub (May 2, 2022): I already have tor enabled and started on my system, is there a reason that the tor option isn't available? I will contact the maintainer.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/whoogle-search#472
No description provided.