Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1Sample init scripts and service configuration for bitcoind2==========================================================4Sample scripts and configuration files for systemd, Upstart and OpenRC5can be found in the contrib/init folder.7contrib/init/bitcoind.service: systemd service unit configuration8contrib/init/bitcoind.openrc: OpenRC compatible SysV style init script9contrib/init/bitcoind.openrcconf: OpenRC conf.d file10contrib/init/bitcoind.conf: Upstart service configuration file11contrib/init/bitcoind.init: CentOS compatible SysV style init script13Service User14---------------------------------16All three Linux startup configurations assume the existence of a "bitcoin" user17and group. They must be created before attempting to use these scripts.18The macOS configuration assumes bitcoind will be set up for the current user.20Configuration21---------------------------------23Running bitcoind as a daemon does not require any manual configuration. You may24set the `rpcauth` setting in the `bitcoin.conf` configuration file to override25the default behaviour of using a special cookie for authentication.27This password does not have to be remembered or typed as it is mostly used28as a fixed token that bitcoind and client programs read from the configuration29file, however it is recommended that a strong and secure password be used30as this password is security critical to securing the wallet should the31wallet be enabled.33If bitcoind is run with the "-server" flag (set by default), and no rpcpassword is set,34it will use a special cookie file for authentication. The cookie is generated with random35content when the daemon starts, and deleted when it exits. Read access to this file36controls who can access it through RPC.38By default the cookie is stored in the data directory, but its location can be39overridden with the option `-rpccookiefile`. Default file permissions for the40cookie are "owner" (i.e. user read/writeable) via default application-wide file41umask of `0077`, but these can be overridden with the `-rpccookieperms` option.43This allows for running bitcoind without having to do any manual configuration.45`conf`, `pid`, and `wallet` accept relative paths which are interpreted as46relative to the data directory. `wallet` *only* supports relative paths.48To generate an example configuration file that describes the configuration settings,49see [contrib/devtools/README.md](../contrib/devtools/README.md#gen-bitcoin-confsh).51Paths52---------------------------------54### Linux56All three configurations assume several paths that might need to be adjusted.58Binary: /usr/bin/bitcoind59Configuration file: /etc/bitcoin/bitcoin.conf60Data directory: /var/lib/bitcoind61PID file: /var/run/bitcoind/bitcoind.pid (OpenRC and Upstart) or62/run/bitcoind/bitcoind.pid (systemd)63Lock file: /var/lock/subsys/bitcoind (CentOS)65The PID directory (if applicable) and data directory should both be owned by the66bitcoin user and group. It is advised for security reasons to make the67configuration file and data directory only readable by the bitcoin user and68group. Access to bitcoin-cli and other bitcoind rpc clients can then be69controlled by group membership.71NOTE: When using the systemd .service file, the creation of the aforementioned72directories and the setting of their permissions is automatically handled by73systemd. Directories are given a permission of 710, giving the bitcoin group74access to files under it _if_ the files themselves give permission to the75bitcoin group to do so. This does not allow76for the listing of files under the directory.78NOTE: It is not currently possible to override `datadir` in79`/etc/bitcoin/bitcoin.conf` with the current systemd, OpenRC, and Upstart init80files out-of-the-box. This is because the command line options specified in the81init files take precedence over the configurations in82`/etc/bitcoin/bitcoin.conf`. However, some init systems have their own83configuration mechanisms that would allow for overriding the command line84options specified in the init files (e.g. setting `BITCOIND_DATADIR` for85OpenRC).87### macOS89Binary: /usr/local/bin/bitcoind90Configuration file: ~/Library/Application Support/Bitcoin/bitcoin.conf91Data directory: ~/Library/Application Support/Bitcoin92Lock file: ~/Library/Application Support/Bitcoin/.lock94Installing Service Configuration95-----------------------------------97### systemd99Installing this .service file consists of just copying it to100/usr/lib/systemd/system directory, followed by the command101`systemctl daemon-reload` in order to update running systemd configuration.103To test, run `systemctl start bitcoind` and to enable for system startup run104`systemctl enable bitcoind`106NOTE: When installing for systemd in Debian/Ubuntu the .service file needs to be copied to the /lib/systemd/system directory instead.108### OpenRC110Rename bitcoind.openrc to bitcoind and drop it in /etc/init.d. Double111check ownership and permissions and make it executable. Test it with112`/etc/init.d/bitcoind start` and configure it to run on startup with113`rc-update add bitcoind`115### Upstart (for Debian/Ubuntu based distributions)117Upstart is the default init system for Debian/Ubuntu versions older than 15.04. If you are using version 15.04 or newer and haven't manually configured upstart you should follow the systemd instructions instead.119Drop bitcoind.conf in /etc/init. Test by running `service bitcoind start`120it will automatically start on reboot.122NOTE: This script is incompatible with CentOS 5 and Amazon Linux 2014 as they123use old versions of Upstart and do not supply the start-stop-daemon utility.125### CentOS127Copy bitcoind.init to /etc/init.d/bitcoind. Test by running `service bitcoind start`.129Using this script, you can adjust the path and flags to the bitcoind program by130setting the BITCOIND and FLAGS environment variables in the file131/etc/sysconfig/bitcoind. You can also use the DAEMONOPTS environment variable here.133### macOS135Copy org.bitcoin.bitcoind.plist into ~/Library/LaunchAgents. Load the launch agent by136running `launchctl load ~/Library/LaunchAgents/org.bitcoin.bitcoind.plist`.138This Launch Agent will cause bitcoind to start whenever the user logs in.140NOTE: This approach is intended for those wanting to run bitcoind as the current user.141You will need to modify org.bitcoin.bitcoind.plist if you intend to use it as a142Launch Daemon with a dedicated bitcoin user.144Auto-respawn145-----------------------------------147Auto respawning is currently only configured for Upstart and systemd.148Reasonable defaults have been chosen but YMMV.
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.