LIGHTNING-CONNECT(7)
π LIGHTNING-CONNECT π
okay bestie, welcome to the lightning-connect page β that's section 7 of the manual, for the record, and it's all about the connect command, aka how you link up with another lightning node π«Ά
β¨ NAME β¨
connect β the command for connecting to another lightning node. that's it, that's the vibe π¦
β¨ SYNOPSIS β¨
connect id [host] [port]
β¨ DESCRIPTION β¨
so the connect RPC command is what establishes a brand-new connection with another node on the Lightning Network. it's giving first contact π
but lowkey important: connecting to a node is just the first step in opening a channel with another node. once the peer is connected, you can open a channel with lightning-fundchannel(7). one thing at a time, bestie π
and if there are active channels with the peer, connect returns once all the subdaemons are in place to handle the channels, not just once it's connected. like it's not done until the whole squad is assembled, periodt β¨
id(string) β the target node's public key. as a convenience,idmay be of the formid@hostorid@host:portβ in which case thehostandportparameters must be omitted. π this can fail if your C-lightning node is a fresh install that has not connected to any peers yet (your node has no gossip yet), or if the targetidis a fresh install that has no channels yet (nobody will gossip about a node until it has one published channel). no cap, the gossip pipeline needs something to talk about πhost(string, optional) β the peer's hostname or IP address. ifhostis not specified (or doesn't work), the connection will be attempted to an IP belonging toidobtained through gossip with other already connected peers. and ifhostbegins with a/it is interpreted as a local path and the connection will be made to that local socket (seebind-addrinlightningd-config(5)). slay, sockets π§port(u16, optional) β the peer's port number. if not specified, the port depends on the current network:- bitcoin mainnet:
9735. - bitcoin testnet:
19735. - bitcoin signet:
39735. - bitcoin regtest:
19846.
- bitcoin mainnet:
β¨ RETURN VALUE β¨
on success, an object is returned, containing all this good stuff:
id(pubkey) β the peer we connected to. hi bestie π«Άfeatures(hex) β BOLT 9 features bitmap offered by peer.direction(string) (one of"in","out") β whether they initiated connection or we did. main character energy either way πaddress(object) β address information (mainly useful ifdirectionisout).:type(string) (one of"local socket","ipv4","ipv6","torv2","torv3") β type of connection (torv2/torv3only ifdirectionisout).- if
typeis"local socket":socket(string) β socket filename. - if
typeis"ipv4","ipv6","torv2"or"torv3":address(string) β address in expected format for type.port(u16) β port number.
β¨ ERRORS β¨
on failure, one of these will come back at you π
400: unable to connect, no address known for peer401: if some addresses are known but connecting to all of them failed, the message will contain details about the failures402: if the peer disconnected while we were connecting-32602: if the given parameters are wrong
π ngl, 402 is the "it's not me, it's you" of error codes. they left mid-conversation.
β¨ AUTHOR β¨
Rusty Russell rusty@rustcorp.com.au is mainly responsible. Felix fixone@gmail.com is the original author of this manpage. legends, both of them π
β¨ SEE ALSO β¨
lightning-fundchannel(7), lightning-listpeers(7), lightning-listchannels(7), lightning-disconnect(7) β the whole friend group πΈ
β¨ RESOURCES β¨
main web site: https://github.com/ElementsProject/lightning β
β¨ EXAMPLES β¨
Example 1 π¦
Request:
$ lightning-cli connect -k "id"="nodeid020202020202020202020202020202020202020202020202020202020202" "host"="localhost" "port"=19735
{
"id": "example:connect#1",
"method": "connect",
"params": {
"id": "nodeid020202020202020202020202020202020202020202020202020202020202",
"host": "localhost",
"port": 19735
}
}
Response:
{
"id": "nodeid020202020202020202020202020202020202020202020202020202020202",
"features": "0898882a8a59a1",
"direction": "out",
"address": {
"type": "ipv4",
"address": "127.0.0.1",
"port": 19735
}
}
Example 2 π
Request:
$ lightning-cli connect -k "id"="nodeid030303030303030303030303030303030303030303030303030303030303" "host"="localhost" "port"=19736
{
"id": "example:connect#2",
"method": "connect",
"params": {
"id": "nodeid030303030303030303030303030303030303030303030303030303030303",
"host": "localhost",
"port": 19736
}
}
Response:
{
"id": "nodeid030303030303030303030303030303030303030303030303030303030303",
"features": "0898882a8a59a1",
"direction": "out",
"address": {
"type": "ipv4",
"address": "127.0.0.1",
"port": 19736
}
}
and that's the whole page, bestie π this lil rewrite was brought to you by Core Lightning v26.06.9, living under the LIGHTNING-CONNECT(7) heading β go forth and connect, you've got this πβ¨
π¦ where this page comes from
- nixpkgs unstable: clightning 26.06.9
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms