electrs: Bug: electrs terminates with "Address already in use (os error 98)"
Describe the bug
After upgrade to electrs 0.9.0 (from 0.8.6), the database migration is successful. But electrs terminates regularly (around 2 minutes after restart), after utilizing 100% CPU, with error messages:
Address already in use (os error 98)
or
JSON-RPC error: transport error: Couldn't connect to host: Cannot assign requested address (os error 99)
Electrs version 0.9.0
Configuration
# Bitcoin Core settings
network = "bitcoin"
daemon_dir= "/var/lib/bitcoin"
daemon_rpc_addr = "127.0.0.1:8332"
# Electrs settings
electrum_rpc_addr = "127.0.0.1:50001"
db_dir = "/var/lib/electrs/db"
index_lookup_limit = 1000
# Logging
verbose = 2
timestamp = true
rust_backtrace = true
Error log
Oct 07 17:58:33 nuc systemd[1]: Started Electrs daemon.
Oct 07 17:58:33 nuc electrs[7361]: Config { network: Bitcoin, db_path: "/var/lib/electrs/db/bitcoin", daemon_dir: "/var/lib/bitcoin", daemon_auth: UserPass("sensitive", "<sensitive>"), daemon_rpc_addr: V4(127.0.0.1:8332), daemon_p2p_addr: V4(127.0.0.1:8333), electrum_rpc_addr: V4(127.0.0.1:50001), monitoring_addr: V4(127.0.0.1:4224), wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: Some(1000), auto_reindex: true, ignore_mempool: false, sync_once: false, server_banner: "Welcome to electrs 0.9.0 (Electrum Rust Server)!", args: [] }
Oct 07 17:58:33 nuc electrs[7361]: [2021-10-07T15:58:33.748Z INFO electrs::db] "/var/lib/electrs/db/bitcoin": 132 SST files, 31.88136245 GB, 3.971850754 Grows
Oct 07 17:58:37 nuc electrs[7361]: [2021-10-07T15:58:37.183Z INFO electrs::chain] loading 703965 headers, tip=000000000000000000086d6c9d2a042e8a6a8b0a64aec0aafd2b331428a1c2f7
Oct 07 17:58:40 nuc electrs[7361]: [2021-10-07T15:58:40.738Z INFO electrs::chain] chain updated: tip=000000000000000000086d6c9d2a042e8a6a8b0a64aec0aafd2b331428a1c2f7, height=703965
Oct 07 17:58:40 nuc electrs[7361]: [2021-10-07T15:58:40.804Z INFO electrs::index] indexing 6 blocks: [703966..703971]
Oct 07 17:58:41 nuc electrs[7361]: [2021-10-07T15:58:41.172Z INFO electrs::chain] chain updated: tip=00000000000000000007549cac7664af5f2185862738e08805d1b440a0567181, height=703971
Oct 07 17:59:45 nuc electrs[7361]: [2021-10-07T15:59:45.539Z INFO electrs::db] closing DB at /var/lib/electrs/db/bitcoin
Oct 07 17:59:45 nuc electrs[7361]: Error: server failed
Oct 07 17:59:45 nuc electrs[7361]: Caused by:
Oct 07 17:59:45 nuc electrs[7361]: Address already in use (os error 98)
Oct 07 17:59:45 nuc systemd[1]: electrs.service: Main process exited, code=exited, status=1/FAILURE
Oct 07 17:59:45 nuc systemd[1]: electrs.service: Failed with result 'exit-code'.
and sometimes
Oct 07 17:20:41 nuc electrs[8135]: Error: daemon not available
Oct 07 17:20:41 nuc electrs[8135]: Caused by:
Oct 07 17:20:41 nuc electrs[8135]: JSON-RPC error: transport error: Couldn't connect to host: Cannot assign requested address (os error 99)
Oct 07 17:20:41 nuc systemd[1]: electrs.service: Main process exited, code=exited, status=1/FAILURE
Oct 07 17:20:41 nuc systemd[1]: electrs.service: Failed with result 'exit-code'.
System running electrs Deployment method: manual Operating System: Ubuntu 18.04.6 LTS Kernel: Linux 4.15.0-159-generic Architecture: x86-64
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 17 (11 by maintainers)
Could you run
lsof -i :50001under root to check if it’s actually electrs trying to bind multiple times?It is used to prevent loading “too popular addresses” (having more than
index_lookup_limitfunding transactions), e.g. https://blockstream.info/address/1CK6KHY6MHgYvmRQ4PAafKYDrg1ejbH1cE.It seems to come from here: https://github.com/rust-bitcoin/rust-bitcoincore-rpc/blob/27d354338e8da01b2f79e7e34eb42732859ebe7b/client/src/client.rs#L1151
Could you please see if electrs works with
--ignore-mempool? It should result in much less RPCs to bitcoind.Thanks for responding so fast! That’s a very long log, but I’ll break it down. First a whole lot of this:
Then a whole lot of that:
Definitely no other instance of electrs running. I stopped the service, replaced the binary, restarted it. Then, the database migration took place successfully (size of ./db/bitcoin is around 30G, that should be ok?) Also, I get the same error after reboot. And it worked perfectly using the 0.8.6 binary - haven’t changed anything else.