<p>I found the answer. It was not too hard. You should make a separate Tor hidden service for the ElectrumX server. The following two links helped me:</p>
<ul>
<li><a href="https://www.reddit.com/r/Electrum/comments/ggmduo/electrumx_over_tor_configuration_help/" rel="nofollow noreferrer">https://www.reddit.com/r/Electrum/comments/ggmduo/electrumx_over_tor_configuration_help/</a></li>
<li><a href="https://en.bitcoin.it/wiki/Setting_up_a_Tor_hidden_service" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Setting_up_a_Tor_hidden_service</a></li>
</ul>
<p>To create a hidden service, you should take the following steps:</p>
<ol>
<li>You must have tor (at least version 0.2.7.1) installed on your host. You don't need to install it on the docker container.</li>
<li>To establish a hidden service, open <code>torcc</code> file (probably you can find it at <code>/etc/tor/torrc</code>). Add these lines to the file:</li>
</ol>
<pre><code>HiddenServiceDir /var/lib/tor/electrumX_service/
HiddenServiceVersion 2
HiddenServicePort 50001 127.0.0.1:50001
HiddenServicePort 50002 127.0.0.1:50002
</code></pre>
<ol start="3">
<li>Restart tor by running this command: <code>sudo service tor restart</code></li>
<li>To see the hostname of the new hidden service (electrumX_service), run <code>sudo cat /var/lib/tor/electrumX_service/hostname</code>. you will see the hostname. For example, my hostname is <code>dpojvtzgm5dcg5ds.onion</code>.</li>
<li>Now, you should set the REPORT_SERVICES environment variable in the ElectrumX container. To do this, you can set it at the beginning, when you want to run the container. I use the following command to run the container: (use the recently created hostname address for the REPORT_SERVICES environment variable.)</li>
</ol>
<pre><code>docker run --name=electrumx --rm --network=host -v /home/taghi/Taghi/docker-electrumx/electrumx:/data \
-e DAEMON_URL=http://MY_BITCOIN_CORE_USERNAME:MY_BITCOIN_CORE_PASSWORD@127.0.0.1:8332 \
-e COIN=BitcoinSegwit \
-e REPORT_SERVICES=tcp://dpojvtzgm5dcg5ds.onion:50001,ssl://dpojvtzgm5dcg5ds.onion:50002 \
lukechilds/electrumx
</code></pre>
<ol start="6">
<li>you can connect to the ElectrumX server by an Electrum client to check if it is working correctly. Furthermore, you can add it to this <a href="https://1209k.com/bitcoin-eye/ele.php" rel="nofollow noreferrer">Server list </a>.</li>
</ol>
<p><strong>Remember:</strong> I have exposed 50001, 50002, 50004, and 8000 ports in the above Dockerfile.</p>

CC BY-SA 4.0
2020-07-21T19:34:19.320Z
2020-07-21T19:34:19.320Z
Taghi
<p>I am trying to run an ElectrumX server on my PC. I run it on a docker container with the following Dockerfile configuration:</p>
<pre><code>FROM python:3.7-alpine3.11
LABEL maintainer=&quot;Luke Childs &lt;lukechilds123@gmail.com&gt;&quot;

COPY ./bin /usr/local/bin
COPY ./VERSION /tmp

RUN VERSION=$(cat /tmp/VERSION) &amp;&amp; \
    chmod a+x /usr/local/bin/* &amp;&amp; \
    apk add --no-cache git build-base openssl &amp;&amp; \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/main leveldb-dev &amp;&amp; \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb-dev &amp;&amp; \
    pip install aiohttp pylru plyvel websockets python-rocksdb &amp;&amp; \
    git clone -b $VERSION https://github.com/kyuupichan/electrumx.git &amp;&amp; \
    cd electrumx &amp;&amp; \
    python setup.py install &amp;&amp; \
    apk del git build-base &amp;&amp; \
    rm -rf /tmp/*

VOLUME [&quot;/data&quot;]
ENV HOME /data
ENV ALLOW_ROOT 1
ENV DB_DIRECTORY /data
ENV SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc://0.0.0.0:8000
ENV SSL_CERTFILE ${DB_DIRECTORY}/electrumx.crt
ENV SSL_KEYFILE ${DB_DIRECTORY}/electrumx.key
ENV HOST &quot;&quot;
WORKDIR /data

EXPOSE 50001 50002 50004 8000

CMD [&quot;init&quot;]

</code></pre>
<p>I want to advertise the ElectrumX server as a Tor hidden server. My bitcoin-core is also reachable by an .onion address: <a href="https://bitnodes.io/nodes/j3zla562edof65jn.onion-8333/" rel="nofollow noreferrer">j3zla562edof65jn.onion</a>. How can I configure the ElectrumX hidden server? What will be the .onion address of the server? I cannot access the ElectrumX from my electrum client using j3zla562edof65jn.onion address. Also, the status of the server is Closed in the <a href="https://1209k.com/bitcoin-eye/ele.php" rel="nofollow noreferrer">Servers list</a>.</p>
<p>Many Thanks.</p>

<electrum><spv><tor>
ElectrumX server as a Tor hidden service
Taghi
# ElectrumX server as a Tor hidden service

(Asked by: username_0 on 2020-07-20)

I am trying to run an ElectrumX server on my PC. I run it on a docker container with the following Dockerfile configuration:
FROM python:3.7-alpine3.11
LABEL maintainer="Luke Childs "

COPY ./bin /usr/local/bin
COPY ./VERSION /tmp

RUN VERSION=$(cat /tmp/VERSION) && \
    chmod a+x /usr/local/bin/* && \
    apk add --no-cache git build-base openssl && \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.11/main leveldb-dev && \
    apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb-dev && \
    pip install aiohttp pylru plyvel websockets python-rocksdb && \
    git clone -b $VERSION https://github.com/kyuupichan/electrumx.git && \
    cd electrumx && \
    python setup.py install && \
    apk del git build-base && \
    rm -rf /tmp/*

VOLUME ["/data"]
ENV HOME /data
ENV ALLOW_ROOT 1
ENV DB_DIRECTORY /data
ENV SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc://0.0.0.0:8000
ENV SSL_CERTFILE ${DB_DIRECTORY}/electrumx.crt
ENV SSL_KEYFILE ${DB_DIRECTORY}/electrumx.key
ENV HOST ""
WORKDIR /data

EXPOSE 50001 50002 50004 8000

CMD ["init"]


I want to advertise the ElectrumX server as a Tor hidden server. My bitcoin-core is also reachable by an .onion address: j3zla562edof65jn.onion. How can I configure the ElectrumX hidden server? What will be the .onion address of the server? I cannot access the ElectrumX from my electrum client using j3zla562edof65jn.onion address. Also, the status of the server is Closed in the Servers list.
Many Thanks.

**Tags:** electrum, spv, tor


---

## 1 answers

### Answer by username_0 on 2020-07-21. Score: 0 | Accepted answer

I found the answer. It was not too hard. You should make a separate Tor hidden service for the ElectrumX server. The following two links helped me:

https://www.reddit.com/r/Electrum/comments/ggmduo/electrumx_over_tor_configuration_help/
https://en.bitcoin.it/wiki/Setting_up_a_Tor_hidden_service

To create a hidden service, you should take the following steps:

You must have tor (at least version 0.2.7.1) installed on your host. You don't need to install it on the docker container.
To establish a hidden service, open torcc file (probably you can find it at /etc/tor/torrc). Add these lines to the file:

HiddenServiceDir /var/lib/tor/electrumX_service/
HiddenServiceVersion 2
HiddenServicePort 50001 127.0.0.1:50001
HiddenServicePort 50002 127.0.0.1:50002


Restart tor by running this command: sudo service tor restart
To see the hostname of the new hidden service (electrumX_service), run sudo cat /var/lib/tor/electrumX_service/hostname. you will see the hostname. For example, my hostname is dpojvtzgm5dcg5ds.onion.
Now, you should set the REPORT_SERVICES environment variable in the ElectrumX container. To do this, you can set it at the beginning, when you want to run the container. I use the following command to run the container: (use the recently created hostname address for the REPORT_SERVICES environment variable.)

docker run --name=electrumx --rm --network=host -v /home/taghi/username_0/docker-electrumx/electrumx:/data \
-e DAEMON_URL=http://MY_BITCOIN_CORE_USERNAME:MY_BITCOIN_CORE_PASSWORD@127.0.0.1:8332 \
-e COIN=BitcoinSegwit \
-e REPORT_SERVICES=tcp://dpojvtzgm5dcg5ds.onion:50001,ssl://dpojvtzgm5dcg5ds.onion:50002 \
lukechilds/electrumx


you can connect to the ElectrumX server by an Electrum client to check if it is working correctly. Furthermore, you can add it to this Server list .

Remember: I have exposed 50001, 50002, 50004, and 8000 ports in the above Dockerfile.


---

