# Getting auto-relay to work

**URL:** <https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140>\
**Category:** Help\
**Created:** [April 1, 2019, 3:12pm UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140 "2019-04-01T15:12:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rytiss](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/rytiss/32/2307_2.png) [@Rytiss](https://discuss.ipfs.tech/u/Rytiss)\
**Post date:** [April 1, 2019, 3:12pm UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/1 "2019-04-01T15:12:57Z")

</div>

I am currently trying to get auto-relay feature to work to transfer files between to NAT’ed nodes.

I add a file with `ipfs add` on a node behind NAT, get the hash and try to `ipfs cat Qm...`it on another node, but it never resolves. `ipfs dht findprovs Qm...` also does not resolve. I do see both nodes connected to other nodes, but I don’t see any relay nodes in `ipfs swarm peers` (the relays occasionally come and go, never matching on both of the nodes, which I think is a prerequisite for auto-relay to work).

Attempting to fetch from a public gateway (e.g. `https://cloudflare-ipfs.com/ipfs/Qm...`) also does not resolve, but I think that’s because I am not connected to a relay node.

I have some configuration changes that may impact the way it works (this is configured to minimize the impact on the local network and to avoid firewall blocks/notices):

```auto
Swarm.ConnMgr.HighWater = 160;
Swarm.ConnMgr.LowWater = 80;
Swarm.EnableAutoRelay = true;
Discovery.MDNS.Enabled = false;
Addresses.Swarm = ['/ip4/127.0.0.1/tcp/4001'];

```

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [April 2, 2019, 12:15am UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/2 "2019-04-02T00:15:35Z")

</div>

> [@Rytiss](#):
>
> ```auto
> Addresses.Swarm = ['/ip4/127.0.0.1/tcp/4001'];
> 
> ```

Why are you using `127.0.0.1` instead of `0.0.0.0` for your swarm port? I think this means your node’s swarm port will only be reachable from other IPFS nodes on localhost (likely none unless you set up multiple local nodes on the same machine).

---

<div class="post-metadata">

**Author:** ![Rytiss](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/rytiss/32/2307_2.png) [@Rytiss](https://discuss.ipfs.tech/u/Rytiss)\
**Post date:** [April 2, 2019, 6:29am UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/3 "2019-04-02T06:29:45Z")

</div>

My external ports are closed anyway, so no point in trying to listen on an ip/port that is going to both a) be blocked and b) notify network admin through a firewall. As far as I understand, this would still allow a node to make outgoing connections, just not accept incoming ones - which is the case for NAT anyway.

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [April 2, 2019, 11:26pm UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/4 "2019-04-02T23:26:32Z")

</div>

I think you’re right.

Have you modified the Adresses.Announce section in the config?

edit: you can ignore this question. I think I got myself confused and I don’t think this would affect auto-relay after all.

I think I’ll need to do more testing to try to recreate your issue.

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [April 3, 2019, 2:28am UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/5 "2019-04-03T02:28:55Z")

</div>

> [@Rytiss](#):
>
> I have some configuration changes that may impact the way it works (this is configured to minimize the impact on the local network and to avoid firewall blocks/notices):
> 
> ```auto
> Swarm.ConnMgr.HighWater = 160;
> Swarm.ConnMgr.LowWater = 80;
> Swarm.EnableAutoRelay = true;
> Discovery.MDNS.Enabled = false;
> Addresses.Swarm = ['/ip4/127.0.0.1/tcp/4001'];
> 
> ```

Are these the _only_ changes to the default config? If not, could you share your `ipfs config show` output?

---

<div class="post-metadata">

**Author:** ![Rytiss](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/rytiss/32/2307_2.png) [@Rytiss](https://discuss.ipfs.tech/u/Rytiss)\
**Post date:** [April 3, 2019, 6:21am UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/6 "2019-04-03T06:21:53Z")

</div>

These are the only changes.

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [April 7, 2019, 3:06am UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/7 "2019-04-07T03:06:42Z")

</div>

After looking at this some more, I don’t think it’s going to be feasible right now for me to recreate the strict network conditions and NATing your node is behind.

> [@Rytiss](#):
>
> I do see both nodes connected to other nodes, but I don’t see any relay nodes in ipfs swarm peers (the relays occasionally come and go, never matching on both of the nodes, which I think is a prerequisite for auto-relay to work).

How are you using the output of `ipfs swarm peers` to tell which nodes you’re connected to are relays and which ones aren’t? Relay connections should be somewhat protected from being killed by the connection manager, so it’s odd that you’d see them come and go (though I’m not sure how you’re doing this).

I might be missing something [in this thread](https://github.com/libp2p/go-libp2p/pull/454), but I’m not sure that two NATed nodes should need to be connected to the same relay in order for discovery to work. Besides it [taking up to a couple of minutes](https://github.com/ipfs/go-ipfs/pull/5785#issuecomment-447085283) for NAT detection to figure out that relay connections are required, I’m also not sure yet what would prevent a NATed node from successfully advertising relay addresses.

I’m assuming that `ipfs id` never shows any public relay addresses for your NATed node, even after several minutes?

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [April 7, 2019, 12:43pm UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/8 "2019-04-07T12:43:13Z")

</div>

I think I’ve got my connection messed up enough so that my node shouldn’t be dialable by external nodes. However, it’s hit or miss whether I get any relay addresses showing up in `ipfs id`. Or in some cases, it just takes a long time to see public relay addresses show up as addresses for my node.

By looking at the output from `ipfs --debug daemon 2>&1 | grep -E "autonat|autorelay"` I think what might be happening is that AutoNAT is correctly detecting that my node has bad connectivity and I’m connecting to relays (some connection attempts don’t succeed), but maybe it’s taking a while to connect to a relay that has AutoHop enabled (?).

In one test it took maybe 30 minutes for me to get a public relay address to start getting advertised for my node. It looks like there might be some AutoNat/AutoRelay improvements [coming in v0.4.20](https://github.com/ipfs/go-ipfs/issues/6163), so perhaps this experimental feature will see some improvement in the next release.

---

<div class="post-metadata">

**Author:** ![wolneykien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/wolneykien/32/5509_2.png) [@wolneykien](https://discuss.ipfs.tech/u/wolneykien)\
**Post date:** [December 29, 2020, 12:36pm UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/9 "2020-12-29T12:36:44Z")

</div>

> [@leerspace](#):
>
> In one test it took maybe 30 minutes for me to get a public relay address to start getting advertised for my node.

Excuse me, how did you determine that the relay address had been advertised to the network? I’ve examined the debug log of the daemon and unable to find any messages regarding address advertising. I can see relay addresses in `ipfs id` output but how can I be sure that each of these addresses has been advertised to the peers? I.e. some special messages should have been sent to the peers, shouldn’t they?

The following thing caused me to be in doubt about address advertising: an other node that **is connected to the same public relay** can’t find (`ipfs dht findpeer`) my node. From my point of view the routing in that case is straightforward: the other node should ask the public relay (that is already the one of its peers) about my node and get the answer. That can be broken in (only?) two cases: 1) my node doesn’t advertise the relay address to the relay node or 2) the other node doesn’t ask the relay node for my ID (shouldn’t it send `findpeer` queries to all of its peers including the relay?)

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [December 30, 2020, 3:21am UTC](https://discuss.ipfs.tech/t/getting-auto-relay-to-work/5140/10 "2020-12-30T03:21:43Z")

</div>

> [@wolneykien](#):
>
> Excuse me, how did you determine that the relay address had been advertised to the network?

I hadn’t. I had just been monitoring the output of [`ipfs id`](https://docs.ipfs.io/reference/cli/#ipfs-id) and assumed that once a relay address showed up it would start being advertised.
