I'm trying to set up a test-net node that closely resembles my main-net node, but I'm having trouble getting it started with systemctl. I assume my configuration files are the root cause. Journalctl isn't giving me much information:
bitcoind.service: Failed with result 'exit-code'. The service is supposed to be run by service user "bitcoin," and I made sure the configuration and data directoreis, and the files within are owned by that user.
My bitcoind.service file:
[Unit]
Description=Bitcoin Testnet
After=network.target
[Service]
ExecStart=/usr/bin/bitcoind -testnet \
-pid=/run/bitcoind/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf \
-datadir=/var/lib/bitcoind
# Make sure the config directory is readable by the service user
PermissionsStartOnly=true
ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin
# Process management
####################
Type=forking
PIDFile=/run/bitcoind/bitcoind.pid
Restart=on-failure
TimeoutStopSec=600
# Directory creation and permissions
####################################
# Run as bitcoin:bitcoin
User=bitcoin
Group=bitcoin
# /run/bitcoind
RuntimeDirectory=bitcoind
RuntimeDirectoryMode=0710
# /etc/bitcoin
ConfigurationDirectory=bitcoin
ConfigurationDirectoryMode=0710
# /var/lib/bitcoind
StateDirectory=bitcoind
StateDirectoryMode=0710
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Deny access to /home, /root and /run/user
ProtectHome=true
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target
My bitcoin.config file:
coin=testnet
testnet=1
txindex=1
dbcache=1024
listen=1
onion=127.0.0.1:9050
discover=1
proxyrandomize=1
server=1
rpcbind=127.0.0.1
rpcport=18332
rpcauth=:
addresstype=bech32
changetype=bech32
# Options only for mainnet
[main]
# Options only for testnet
[test]
rpcport=18332
# Options only for regtest
[regtest]
EDIT:
I figured it out by trying to run bitcoind from the command line using the same settings as systemctl's bitcoind.service file:
sudo -H -u bitcoin bash -c 'bitcoind -testnet -pid=/run/bitcoind/bitcoind.pid -conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind'
And that resulted in this error:
Error: Config setting for -rpcbind only applied on test network when in [test] section.I fixed it by adding
rpcbind=127.0.0.1 to the [test] section.