question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while connecting to the lightning node via <my external IP>:9735 (The operation was canceled.)

See original GitHub issue

Hello, I try to set up lightning network (lnd 0.5.1) in my store . BTCpay server is on the same machine as lnd and bitcoind. No docker.

I am getting this error: Error: Error while connecting to the lightning node via <my external IP addr>:9735 (The operation was canceled.)

I don’t know why it connects to my external IP (what is of course not reachable from LAN) if I have localhost (127.0.0.1) configured in the connection string:

type=lnd-rest;server=https://127.0.0.1:8080/;macaroonfilepath=/home/user/.lnd/data/chain/bitcoin/mainnet/admin.macaroon;certthumbprint=123456abcdefgh

My lnd.conf is configured:

listen=0.0.0.0:9735
restlisten=127.0.0.1:8080
rpclisten=127.0.0.1:10009
tlsextraip=127.0.0.1
externalip=<my external IP addr>

Do you have some idea for a reason or workaround? Any help very appreciated.

PS: Communication with lnd API works fine for me with this python script:

import base64, codecs, json, requests
url = 'https://localhost:8080/v1/getinfo'
cert_path = '/home/user/.lnd/tls.cert'
macaroon = codecs.encode(open('/home/user/.lnd/data/chain/bitcoin/mainnet/admin.macaroon', 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
r = requests.get(url, headers=headers, verify=cert_path)
print(r.json())

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasDoriercommented, Jan 14, 2019

@jarole I think you are over complicating.

You said that before, it was giving you this:

Error: Error while connecting to the lightning node via <my external IP addr>:9735 (The operation was canceled.)

I guess you talk about the Test connection right? If so, it happen that commercial ISP does not allow to connect to your own router via its public IP from your internal network. If that’s the case and people still can create a channel with you, just use the local network IP inside the connection string in BTCPay settings, check that you can create invoice, and you just ignore the error.

I think your node would have still been visible on 1ml.com or explore.casa, it just takes time to appear.

1reaction
jarolecommented, Jan 14, 2019

To make btcpay working in my environment and to have a correct externalip advertising by my lnd, I have done a “little hack” following these steps:

  1. Add /etc/hosts entry with my my local IP addr 192.168.77.88 to ln.mydomain.com
  2. set externalip=ln.mydomain.com in my lnd.conf (so both services - BTCpay and lnd are resolving ln.mydomain.com to my LAN IP 192.168.77.88)
  3. start lnd, NBxplorer, BTCpay
  4. Configure Lightning Payments in my BTCpay store stores >(store) settings > lightning node modify>test connection
  5. Test passed with msg like

…sucessfully connected to node 030abcd…@192.168.77.88:9735

  1. In this phase, my node is advertising my local IP what is wrong. So I had to change /etc/hosts back and comment out the entry which resolves ln.mydomain.com to my LAN ip 192.168.77.88 When the node will be asked for externalip=ln.mydomain.com it will return my external IP because of DNS resolution and no more entry in /etc/hosts
  2. No restart is needed, my node is now visible on 1ml.com or explore.casa with my external IP
  3. BTCpay is working, channels and LN payments work like a charm.

Sorry for spam, but I’d like to document this behavior of btcpay as detailed as possible. You say that btcpay does not depend on externalip , but I have experienced that btcpay works different with different externalip configured in lnd. Offcourse my lightning port is open (9735). Otherwise I would not be able to open a channel with the node. I can close this issue, but I want to summarize it for people struggling with similar issues. Perhaps somebody finds this usefull somehow.

Thank you for your time and work so far!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Lightning Network FAQ
I get an error (“Unlock Wallet Failed”) when trying to log in to RTL, what can I do? “Server is still in the...
Read more >
Newest 'linux' Questions
Problem with the first Initialization of my LN node, dial tcp my-external-ip:9735: connect: connection timed out. Background I was following 402 Payment ...
Read more >
RASPIBLITZ - How To Run A Lightning and Bitcoin Full Node
This video will walk you through building, setting up and using your own RaspiBlitz node. Open a channel to my lightning node with...
Read more >
Adventures in Running a Bitcoin Lightning Node — Part 1
Running a Bitcoin Lightning Node... I share my learning's, insights and experiences in installing, configuring and bootstrapping a routing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found