Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Detailed guide to installing LND and Bitcoind on Ubuntu 16.04 LTS for Mainnet


This guide is specific to getting LND 0.4.1-beta and Bitcoind running on Ubuntu 16.04 LTS for mainnet.

Original installation guide:

This guide is broken into the following sections:

  • Install bitcoind and set to start automatically
  • Install development tools and dependancies
  • Install lnd, setup a config file, fund and open channels
  • Install supervisor to automatically start lnd

Install bitcoind

Published instructions

Compiling yourself

if you'd prefer to compile bitcoind yourself, please refer to


First add the repository:

sudo apt-add-repository ppa:bitcoin/bitcoin

You will be prompted for your user password. Provide it to continue, and press enter when prompted.

Run the update process:

sudo apt-get update

Then proceed with installing bitcoind as follows:

sudo apt-get install bitcoind

Setup your .bitcoin/bitcoin.conf file, there is a sample here:

Simplest version might be as follows:


Start bitcoind to initiate sync, and be sure to take a look at


You can monitor the progress in the logs:

tail $HOME/.bitcoin/debug.log

Important: The bitcoind sync process can take 3 to 5 days to complete!

(Optional) You can monitor progress with the following:

Install jq to trim the json:

sudo apt-get install jq

Get the current block count and run it through jq:

curl -s |jq -r -c .blocks[0].height

Compare the result to the output of:

bitcoin-cli getblockcount

Alternatively, combine both of these into a convenient one-liner expression:

echo `bitcoin-cli getblockcount 2>&1`/`curl -s |jq -r -c .blocks[0].height 2>/dev/null`

If the output values are the same, then your bitcoind node is fully synced and you can proceed with lnd installation.

Setting up bitcoind to start automatically

To setup bitcoind to start automatically, we'll borrow the systemd setup from the following guide:

Adapted from sources

First make sure bitcoind is fully synced, then stop it with:

bitcoin-cli stop

Add & edit the systemd configuration file:

sudo nano /etc/systemd/system/bitcoind.service

Add in the following text, making sure to replace all instances of USERNAME with your username, or the applicable username bitcoind is being run as:

Description=Bitcoin daemon

ExecStart=/usr/bin/bitcoind -conf=/home/USERNAME/.bitcoin/bitcoin.conf -pid=/home/USERNAME/.bitcoin/


Enable the systemd setup with the following commands:

sudo systemctl enable bitcoind
sudo systemctl start bitcoind

Check it's working properly with:

systemctl status bitcoind

bitcoind should start automatically from here on, and restart if it fails.

Next we need to install go, then lnd.

Install Go

The lnd install guide refers to golang-1.10-go, but Ubuntu 16.04 LTS currently has golang-1.9-go. To install the latest go using snap instead:

sudo snap install --classic go

On success you will see the result:

go 1.10 from 'mwhudson' installed

Create a 'go' directory in your home directory:

mkdir go

Set go paths, this can be done in .profile (which reads .bashrc) or directly in .bashrc:

You might notice some difference between ssh sessions and local terminal sessions with .profile so for the purpose of this guide we'll use .bashrc as the results are the same for both types of session

nano .bashrc

Add to the end:

export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Important: the snap install of go will automatically set the GOROOT variable. It's no longer necessary to set this yourself, unless using apt-get install for older version of go.

Logout and log back in to reread variables, or you can type:

source .bashrc

Check variables with:

go env

And if you see output, go is setup correctly.

Install build tools

lnd is now using dep to manage dependancies, and dep has some additional requirements for development tools, so make sure you have the build-essential package installed:

apt-get install build-essential

Install dep:

go get -u

Install LND

Install lnd by cloning the source, running dep, and then the build commands as follows:

go get -d
cd $GOPATH/src/
make && make install

(Optional) run tests and check for any errors:

make check

Important: this next step requires bitcoind be fully synced!

Run lnd for first run as follows, it will take a while to catch up and perform its own sync:

lnd --bitcoin.mainnet --debuglevel=debug --bitcoin.node=bitcoind --bitcoind.rpcuser=REPLACEME --bitcoind.rpcpass=REPLACEME --externalip=X.X.X.X --bitcoind.zmqpath=tcp://

But before the sync actually starts, in another terminal window you will need to create a wallet, store the recovery key, and then issue the unlock command.

To create a wallet run:

lncli create

An example of the output is as follows. Please ensure you have a strong password with minimum 8 characters, and mix of uppercase and lowercase:

Input wallet password: ********
Confirm wallet password: ********

Do you have an existing cipher seed mnemonic you want to use? (Enter y/n): n

Your cipher seed can optionally be encrypted.
Input your passphrase you wish to encrypt it (or press enter to proceed without a cipher seed passphrase): ********
Confirm cipher seed passphrase: ********

Generating fresh cipher seed...


------------------BEGIN LND CIPHER SEED------------------
 1. one        2. two        3. three        4. four 
 5. five       6. six        7. seven        8. eight
 9. nine      10. ten       11. eleven      12. twelve 
13. thirteen  14. fourteen  15. fifteen     16. sixteen
17. seventeen 18. eighteen  19. nineteen    20. twenty
21. twentyone 22. twentytwo 23. twentythree 24. twentfour
------------------END LND CIPHER SEED--------------------

Copy and paste the cipher seed and store it securely somehow, such a secure note in a password manager, or printed to paper and locked in a safe, or similar.

You will now have to unlock the wallet you just created so lnd can proceed with the initial sync:

lncli unlock

Once sync is complete, proceed with editing a config file so as to start lnd with fewer flags, and later on automatically with a simple command.

Create and edit $HOME/.lnd/lnd.conf from

Simple version might be as follows:

[Application Options]




; The maximum number of channels that should be created.
; autopilot.maxchannels=5
; The percentage of total funds that should be committed to automatic channel
; establishment
; autopilot.allocation=0.6

Thereafter you can start lnd without flags, or using supervisor (see below) or some other option like systemd:


You monitor the log file in the logs directory under $HOME/.lnd/logs/bitcoin/mainnet/lnd.log

To verify lnd is operational, open another terminal window or session and try the following:

lncli getinfo
lncli getnetworkinfo
lncli describegraph

Setup a wallet to deposit some bitcoin:

lncli newaddress p2wkh

Make the deposit and check progress with:

lncli walletbalance 

A confirmed a balance means the deposit is complete and ready for opening channels.

To open your first channel(s) it may be useful to find active nodes. You can do this by browsing the node directory at various explorers such as or you can open channels with the following:

* bitrefill:
* mainnet yalls: 023668a30d0a27304695df3fb1af55a4fb75153eac34840817cae0e6a57894fd51@
* guide author: 02262bbc21c171bc91a1d6bbf89571c95873849b9a60d3ea9671b777d852d39ecd@

Open a channel by first connecting, then opening a channel as follows:

lncli connect pubkey@ip:port
lncli openchannel --node_key=<pubkey> --local_amt=<amount>

Helpful hint:

if mSATs, satoshis, bits, mBTC are confusing, consider installing this useful calculator

Verify pending & open channels using:

lncli pendingchannels
lncli listchannels

Setup Supervisor to run LND automatically

supervisor is one way to start lnd automatically, and automatically restart if it fails.

First exit any running lnd session, and proceed through the following steps:

First install supervisor:

sudo apt-get install supervisor

Then setup the configuration file, sudo access will be required:

cd /etc/supervisor/conf.d
sudo nano lnd.conf

Edit lnd.conf and add the following:

command=/home/USERNAME/go/bin/lnd --configfile=/home/USERNAME/.lnd/lnd.conf

Reload supervisor:

sudo supervisorctl reload

You can monitor the log files by tailing them in the relevant directories in your home directory for lnd, or in /var/log/supervisor/ with sudo access.

Important: If lnd restarts via supervisor for some reason, you will need to unlock your wallet again for the node to go live.

lncli unlock

Email notification of supervisor restart

If you wish to be notified by email when supervisor restarts a process, you can install the superlance plugin:

sudo apt-get install python-pip
sudo -H pip install superlance

Edit supervisor's config file:

sudo nano /etc/supervisor/supervisord.conf

Add the following, changing the email address to your email address:

command=/usr/local/bin/crashmail -p lnd -m your@email.address

This should be followed by updating supervisor, which will also restart lnd, and add the event notifier you've configured:

sudo supervisorctl update

So be sure to unlock your wallet again:

lncli unlock

When a process exits you will now get a notification sent via email and can login to unlock the wallet and take your node fully online again.

That's it, happy channeling. If you liked this guide and got it working, please consider tipping with a microtransaction at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment