# IPFS DHT can't seem to find anything correctly

**URL:** <https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037>\
**Category:** Help\
**Tags:** go-ipfs\
**Created:** [October 11, 2018, 9:16pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037 "2018-10-11T21:16:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![obo20](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/obo20/32/4957_2.png) [@obo20](https://discuss.ipfs.tech/u/obo20)\
**Post date:** [October 11, 2018, 9:16pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/1 "2018-10-11T21:16:45Z")

</div>

I’m in the process of trying to create a service that basically works like this:  
\*People provide me a hash  
\*I pin that hash from the network

I’m having quite a bit of problems with this.

Neither the “ipfs pin add (hash)” and the “ipfs dht findprovs (hash)” commands are finding anything. I’m letting each of these commands run until they naturally time out (which appears to be something like 10minutes) and I still get no results.

The only way either of these commands work is if I’m directly connected to the node I’m trying to grab content from.

I know the content resides on the network, as whenever I visit [ipfs.io/ipfs/myHash](http://ipfs.io/ipfs/myHash), the content is found easily.

Does anybody have any tips on how to make this process actually work in an efficient manner? It’s not feasible for me to have to manually connect to all nodes I’m trying to pin content from, as I often don’t know the multiaddresses of nodes that are hosting the content.

---

<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:** [October 11, 2018, 10:46pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/2 "2018-10-11T22:46:29Z")

</div>

If your node has bad connectivity to other nodes then you’re going to have a bad time.

How many NATs are you behind? Is UPnP enabled? If not, have you opened port 4001?

---

<div class="post-metadata">

**Author:** ![obo20](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/obo20/32/4957_2.png) [@obo20](https://discuss.ipfs.tech/u/obo20)\
**Post date:** [October 12, 2018, 12:12am UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/3 "2018-10-12T00:12:51Z")

</div>

My node is hosted on Digital Ocean. I also tested with another node on AWS EC2.

So neither of those should be behind any NAT.

Port 4001 is also opened up on both machines.

---

<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:** [October 12, 2018, 12:48pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/4 "2018-10-12T12:48:08Z")

</div>

What do you get from the following commands?

1. From a remote machine, `telnet your.digital.ocean.ip 4001`
2. On your DO or AWS IPFS node, `ipfs swarm peers | wc -l`

---

<div class="post-metadata">

**Author:** ![koalalorenzo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/koalalorenzo/32/745_2.png) [@koalalorenzo](https://discuss.ipfs.tech/u/koalalorenzo)\
**Post date:** [October 13, 2018, 8:58am UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/5 "2018-10-13T08:58:29Z")

</div>

Another solution would be to ensure that your nodes are connected to each other! Maybe that works too, I find this a quiet common problem and the only solution is to ensure direct connectivity.

If you have static IP consider to add them as bootstrap nodes too:

```auto
ipfs swarm connect $perr_multiaddress
ipfs bootstrap add $peer_multiaddress

```

you can get the peer multi address by simply running `ipfs id` 🙂

---

<div class="post-metadata">

**Author:** ![obo20](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/obo20/32/4957_2.png) [@obo20](https://discuss.ipfs.tech/u/obo20)\
**Post date:** [October 15, 2018, 2:24pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/6 "2018-10-15T14:24:21Z")

</div>

@leerspace I tried on multiple different machines running the “telnet myDOIP 4001” command and every time received “unable to connect to remote host: connection timed out”

Which is strange to me, as this digital ocean machine has “all ports” opened up for TCP.

---

<div class="post-metadata">

**Author:** ![obo20](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/obo20/32/4957_2.png) [@obo20](https://discuss.ipfs.tech/u/obo20)\
**Post date:** [October 15, 2018, 2:28pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/7 "2018-10-15T14:28:23Z")

</div>

@koalalorenzo I actually do this with many of my nodes. However this is a pretty fragile process, as frequently the nodes forget about each other, and often I run into connectivity errors such as the ones mentioned in this bug report:

> <https://github.com/ipfs/go-ipfs/issues/5588>

As @leerspace mentioned in the bug report, my two issues may be related, but I’m not 100% positive.

Also, on the subject of the nodes forgetting about each other, does anybody know if there is anything on the IPFS roadmap that allows two bootstrapped nodes to stay connected to each other unless manually disconnected? I know for me at least this would be a useful feature.

---

<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:** [October 15, 2018, 4:38pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/8 "2018-10-15T16:38:00Z")

</div>

Assuming the IPFS daemon is running and listening on 4001, that sounds like a firewall issue to me. You should get a multistream response.

When I get a chance I’ll try to set up a droplet and document the process to get a healthy IPFS node running on it.

---

<div class="post-metadata">

**Author:** ![obo20](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/obo20/32/4957_2.png) [@obo20](https://discuss.ipfs.tech/u/obo20)\
**Post date:** [October 15, 2018, 5:25pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/9 "2018-10-15T17:25:56Z")

</div>

I would appreciate that a lot.

If it helps, I’m currently running Ubuntu 16 for my nodes, and have the most current version of IPFS on all of them. I’m also running NGINX in front of them. While I don’t believe that to be causing any issues, it’s something to be aware of.

---

<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:** [October 16, 2018, 12:10am UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/10 "2018-10-16T00:10:49Z")

</div>

TL;DR: It all Just Works® with the vanilla DigitalOcean Ubuntu 16.04 image and DigitalOcean project defaults. I didn’t have any connectivity issues or problems with blocked ports since it turns out that DigitalOcean’s firewall doesn’t appear to block anything by default (nor does Ubuntu).

If you want to skip to what I think the problem is, skip to the very end of this post. Details follow immediately below so it’s clear what I did.

Here’s what I did:

1. Created a DigitalOcean account
2. Created a new project
3. Created the cheapest droplet they have with an ssh key, Ubuntu 16.04, and otherwise default settings
4. ssh-d to the droplet as root with my ssh key
5. `wget https://dist.ipfs.io/go-ipfs/v0.4.17/go-ipfs_v0.4.17_linux-amd64.tar.gz`
6. `tar xvfz go-ipfs_v0.4.17_linux-amd64.tar.gz`
7. `cd go-ipfs/`
8. `./ipfs init --profile=server`
9. `./ipfs daemon`
10. From my home IP, ran `telnet my.do.public.ip 4001` and got a `/multistream/1.0.0` response

This all took about 15 minutes, so I’m curious if they’ll even bother with charging me $0.007 for the droplet’s hourly charge :).

Here’s what I think we need to troubleshoot further:

1. Does your DigitalOcean cloud firewall have _any_ rules (should be none by default)? If so, please post screenshots.
2. Output from `sudo iptables -L -n` on the droplet
3. Output from `sudo ufw status verbose`

If you followed something like [this guide](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04) (which they suggested to me after I created the droplet) for setting up Ubuntu on Digital Ocean, I think it’s likely that you enabled a restrictive firewall on Ubuntu that’s blocking almost everything except for explicitly allowed services.

**Spoiler (or what I think the solution likely is)**  
If this is the case, then you’ll need to run `sudo ufw allow 4001` to open up the port needed for IPFS. Unless there’s a custom DigitalOcean firewall too, then that should allow connections to your daemon’s swarm port.

---

<div class="post-metadata">

**Author:** ![obo20](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/obo20/32/4957_2.png) [@obo20](https://discuss.ipfs.tech/u/obo20)\
**Post date:** [October 16, 2018, 2:49pm UTC](https://discuss.ipfs.tech/t/ipfs-dht-cant-seem-to-find-anything-correctly/4037/11 "2018-10-16T14:49:01Z")

</div>

Thank you so much!

It ended up being that I had accidentally enabled that firewall by following that guide you had linked.

Running sudo ufw allow 4001 fixed the issue.

I seriously appreciate the time you took to help me get this figured out.
