# About IPFS establish connection

**URL:** <https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768>\
**Category:** Kubo\
**Tags:** go-ipfs\
**Created:** [April 23, 2018, 2:36pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768 "2018-04-23T14:36:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![avatar-lavventura](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/avatar-lavventura/32/2890_2.png) [@avatar-lavventura](https://discuss.ipfs.tech/u/avatar-lavventura)\
**Post date:** [April 23, 2018, 2:36pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/1 "2018-04-23T14:36:22Z")

</div>

I am using IPFS version 0.4.4 inside a google instance([https://console.cloud.google.com/](https://console.cloud.google.com/)), I opened its port 4001 and instance has a external IP.

[Here](https://discuss.ipfs.tech/t/ipfs-swarm-connect-connect-failure-dial-attempt-failed-context-deadline-exceeded/2340/6) @VictorBjelkholm recommends me to use following line of code in order to check accessibility of the ipfs-peer:

```auto
$ nc gateway-int.ipfs.io 4001
/multistream/1.0.0

```

> Replace [gateway-int.ipfs.io](http://gateway-int.ipfs.io) 4001 with your IP and your port (defaults to 4001, only use 4003 if you made a choice to change it by changing the config)

[Q] What should I do if `nc peerIP 4001` returns nothing? Since that returns nothing I am not able to make a connection into ipfs-peer using `ipfs swarm connect` 😕

What should I do to make my peer return `/multistream/1.0.0` in order to establish a connection?

Thank you for your help.

---

<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 23, 2018, 5:07pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/2 "2018-04-23T17:07:31Z")

</div>

What does `sudo netstat -lptn | grep 4001` show on the IPFS node you’re trying to connect to?

---

<div class="post-metadata">

**Author:** ![avatar-lavventura](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/avatar-lavventura/32/2890_2.png) [@avatar-lavventura](https://discuss.ipfs.tech/u/avatar-lavventura)\
**Post date:** [April 23, 2018, 7:24pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/3 "2018-04-23T19:24:04Z")

</div>

Again empty string. @leerspace

---

<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 23, 2018, 7:34pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/4 "2018-04-23T19:34:22Z")

</div>

That means there’s nothing listening on port 4001 on the node you’re trying to connect to.

Assuming the daemon is already running on the node you’re trying to connect to, can you post the output of `ipfs config Addresses` from the node you’re trying to connect to?

---

<div class="post-metadata">

**Author:** ![avatar-lavventura](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/avatar-lavventura/32/2890_2.png) [@avatar-lavventura](https://discuss.ipfs.tech/u/avatar-lavventura)\
**Post date:** [April 23, 2018, 7:49pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/5 "2018-04-23T19:49:06Z")

</div>

Sorry I forget to run ipfs daemon &

```auto
$ ipfs daemon &
$ sudo netstat -lptn | grep 4001
tcp 0 0 0.0.0.0:4001 0.0.0.0:* LISTEN 19088/ipfs          
tcp6 0 0 :::4001 :::* LISTEN 19088/ipfs 

$ ipfs config Addresses
{
  "API": "/ip4/127.0.0.1/tcp/5001",
  "Announce": [],
  "Gateway": "/ip4/127.0.0.1/tcp/8080",
  "NoAnnounce": [],
  "Swarm": [
    "/ip4/0.0.0.0/tcp/4001",
    "/ip6/::/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 23, 2018, 7:52pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/6 "2018-04-23T19:52:12Z")

</div>

If you’re running the daemon on a remote server using `ipfs daemon &`, it’s going to get killed when you log out.

Can you try to connect using IPFS while the IPFS daemon is for sure running on the node you’re trying to connect to? If this also doesn’t work, then I suspect there’s something blocking the connection.

---

<div class="post-metadata">

**Author:** ![avatar-lavventura](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/avatar-lavventura/32/2890_2.png) [@avatar-lavventura](https://discuss.ipfs.tech/u/avatar-lavventura)\
**Post date:** [April 23, 2018, 8:10pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/7 "2018-04-23T20:10:59Z")

</div>

I am running IPFS as: `nohup ipfs daemon &`

I guess google-instance blocks it by default, not sure why.

---

<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 23, 2018, 8:31pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/8 "2018-04-23T20:31:47Z")

</div>

Oh, cool. I didn’t know about `nohup`.

I don’t know much about google compute instances beyond [what I can find](https://stackoverflow.com/a/27675578/1388019) by searching around, but how did you try to open port 4001 to your google instance?

---

<div class="post-metadata">

**Author:** ![avatar-lavventura](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/avatar-lavventura/32/2890_2.png) [@avatar-lavventura](https://discuss.ipfs.tech/u/avatar-lavventura)\
**Post date:** [April 23, 2018, 8:41pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/9 "2018-04-23T20:41:58Z")

</div>

I can ping to its IP address also. I have follow the same question’s answer. Let my reboot and try again.

```auto
$ gcloud compute firewall-rules list | grep 'ipfs'
ipfs4001 default INGRESS 1000 tcp:4001

```

---

<div class="post-metadata">

**Author:** ![avatar-lavventura](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/avatar-lavventura/32/2890_2.png) [@avatar-lavventura](https://discuss.ipfs.tech/u/avatar-lavventura)\
**Post date:** [April 23, 2018, 8:45pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/10 "2018-04-23T20:45:54Z")

</div>

I selected:  
`Targets => All instances in the network` and it works! I guess by default its blocked by the firewall.

Thanks for the help @leerspace

---

<div class="post-metadata">

**Author:** ![EnchanterIO](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/enchanterio/32/928_2.png) [@EnchanterIO](https://discuss.ipfs.tech/u/EnchanterIO)\
**Post date:** [June 5, 2018, 7:42am UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/11 "2018-06-05T07:42:43Z")

</div>

I am trying to connect from my local docker to a remote IPFS node I have running.

I am able to NC and get the multistream response but then the NC command never terminates, keep hanging, not sure if that’s expected?

```
root@6c5fbf58bf1f:/go# nc <IP> 4001
/multistream/1.0.0
^C

```

And connecting results in deadline error:

```
ipfs swarm connect /ip4/<IP>/tcp/4001/ipfs/Qm...w3hb7

```

failure: dial attempt failed: context deadline exceeded

IPFS VERSION: go-ipfs/0.4.16-dev/

Any idea?

Update: doesn’t work neither from my local machine so is not a docker issue, my remote node is running in gcloud with exposed port.

Update2: i am able to connect from another gcloud node so maybe it’s something gcloud related.  
Update3: the external loadbalancer port is exposed correctly so no idea what’s the issue:

```
kubectl expose pod ipfs-pod --type=LoadBalancer --name ipfs-ext --port=4001 --target-port=4001
```

---

<div class="post-metadata">

**Author:** ![EnchanterIO](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/enchanterio/32/928_2.png) [@EnchanterIO](https://discuss.ipfs.tech/u/EnchanterIO)\
**Post date:** [June 5, 2018, 9:45am UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/12 "2018-06-05T09:45:37Z")

</div>

I also added a general firewall rule to allow all tcp:4001 ingress/egress traffic on all gcloud machines. What else could it be? 😕 @leerspace @avatar-lavventura

Update: I also opened the 4001 TCP port on my localhost just in case but no success. Still with the same error.

Update: neither works on IPFS 0.4.15 official release so is not the dev version issue.

hey @whyrusleeping, did u experienced such a problem in the past?

---

<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:** [June 5, 2018, 2:00pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/13 "2018-06-05T14:00:52Z")

</div>

> [@EnchanterIO](#):
>
> I am able to NC and get the multistream response but then the NC command never terminates, keep hanging, not sure if that’s expected?

This is expected and what I see with my own nodes.

> [@EnchanterIO](#):
>
> Update2: i am able to connect from another gcloud node so maybe it’s something gcloud related.

This is what it sounds like to me – either something specific to gcloud in general or the load balancer. How many nodes do you have behind the load balanced IP? This is just an idea (should be taken with a grain of salt since I’ve never used gcloud and I’m making assumptions about your setup), but if you issue the `ipfs swarm connect` command with a given IP and node ID and there are multiple nodes with different IDs behind the load-balanced IP, then if the load-balancer directs you to a different node than the one you specified I’d expect the connection to fail.

---

<div class="post-metadata">

**Author:** ![EnchanterIO](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/enchanterio/32/928_2.png) [@EnchanterIO](https://discuss.ipfs.tech/u/EnchanterIO)\
**Post date:** [June 5, 2018, 2:20pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/14 "2018-06-05T14:20:57Z")

</div>

it’s only one. The reason of load balancer is to have a never changing IP. Anyway, if I am getting the “/multistream/1.0.0” response then it means the connection is working fine isn’t? Why would the swarm connect fail then? @leerspace

---

<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:** [June 5, 2018, 2:48pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/15 "2018-06-05T14:48:42Z")

</div>

It means there’s an IPFS node listening at that IP address. My idea was that the load balancer was directing the connection to the load-balanced IP to the wrong node, but if there’s only one node then that obviously can’t be it.

Assuming you’ve already done what worked for the OP in this thread, I don’t currently have any other ideas of things to check unless you can try removing the load balancer from the equation.

---

<div class="post-metadata">

**Author:** ![EnchanterIO](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/enchanterio/32/928_2.png) [@EnchanterIO](https://discuss.ipfs.tech/u/EnchanterIO)\
**Post date:** [June 5, 2018, 3:26pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/16 "2018-06-05T15:26:53Z")

</div>

yea that’s actually what i was thinking as well. Tomorrow I will deploy a new pod without load balancer and try to connect. If you have time you can try to create your little cluster as well. I think people must have tried setup IPFS on aws/gcloud already hm.

Will keep this thread updated.

---

<div class="post-metadata">

**Author:** ![EnchanterIO](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/enchanterio/32/928_2.png) [@EnchanterIO](https://discuss.ipfs.tech/u/EnchanterIO)\
**Post date:** [June 6, 2018, 7:29am UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/17 "2018-06-06T07:29:26Z")

</div>

It’s the second day I am trying to make it work without success. I removed one load balancer in the middle but the same problem persist. The thing is in google cloud u must have the load balancer because that’s what exposes your external IP. But anyway, i am able to get the “multistream” response so the communication is possible 😕

I created completely new pod, service, virtual machine under a different name to be sure the request doesn’t get lost somewhere and no luck. Anyone would like to try it himself?

---

<div class="post-metadata">

**Author:** ![EnchanterIO](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/enchanterio/32/928_2.png) [@EnchanterIO](https://discuss.ipfs.tech/u/EnchanterIO)\
**Post date:** [June 6, 2018, 8:15am UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/18 "2018-06-06T08:15:59Z")

</div>

SOLVED!!! god damn, this co-working space in Barcelona seems to be messing with firewall I think… I tried to connect my laptop to my wifi hotspot from phone and now it works… omg, like 10h bug.

---

<div class="post-metadata">

**Author:** ![murisimov](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/murisimov/32/1048_2.png) [@murisimov](https://discuss.ipfs.tech/u/murisimov)\
**Post date:** [June 6, 2018, 9:39am UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/19 "2018-06-06T09:39:57Z")

</div>

@leerspace  
Hey!  
Seems like I have a similar issue, messing with this two days already and I’ll be very very grateful for help.  
I’m playing with ipfs-cluster and its pins do not work well.

`pin_timeout` is set to `30m` in ipfs-cluster config.  
I do:

```auto
ipfs add <file>

```

then

```auto
ipfs-cluster-ctl pin add <hash>

```

`ipfs-cluster-ctl status` says that it’s `PINNED` on the node that executes these commands, but it remains `PINNING` on the other node, typically ending up with the following message in the other node’s log:

```auto
09:20:54.539 ERROR ipfshttp: error posting to IPFS:Post http://127.0.0.1:5001/api/v0/refs?arg=QmZT5FuxLk2CbH7415qn7dZsfnR5to142k1FaNMdp8X4Cv&recursive=true: context deadline exceeded ipfshttp.go:775
09:20:54.540 ERROR p2p-gorpc: Post http://127.0.0.1:5001/api/v0/refs?arg=QmZT5FuxLk2CbH7415qn7dZsfnR5to142k1FaNMdp8X4Cv&recursive=true: context deadline exceeded client.go:245

```

Only once it went through, but I suppose that the file was taken from the public nodes, since the file’s content was as simple as `foobar`.

I googled a bit and figured out that nodes should be able to see each other in the swarm.

But when I try to connect with

```auto
ipfs -D swarm connect /ip4/<ip>/tcp/4001/ipfs/<hash>

```

I get this:

```auto
Error: connect <hash> failure: dial attempt failed: failed to dial <peer.ID eXAr9a> (default failure)

```

Instantly, and ipfs -D gives nothing too.

Meanwhile the firewalls seems to be OK, no rules at iptables, and when I do

```auto
nc -v <ip> 4001

```

I get

```auto
Connection to <ip> 4001 port [tcp/*] succeeded!

```

And I get `Connection refused` for closed ports. Though, no `/multistream/1.0.0` message appears event in debug mode.

Any ideas what could be wrong with the swarm connection, and could it affect cluster pinning?

---

<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:** [June 6, 2018, 12:13pm UTC](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768/20 "2018-06-06T12:13:54Z")

</div>

> [@murisimov](#):
>
> Though, no /multistream/1.0.0 message appears event in debug mode.

That should show up even if you’re not running in debug mode. That you don’t see the message suggests that there’s not an IPFS node listening at that port.

I don’t know much about the setup of ipfs-cluster or any current issues since I haven’t used it before. I’m mostly waiting for the implementation of [cluster sharding](https://github.com/ipfs/ipfs-cluster/issues/309) before I go through the process of setting up a cluster.

[Next page](https://discuss.ipfs.tech/t/about-ipfs-establish-connection/2768.md?page=2)
