"ipfs swarm connect" command returns an error

I’m trying to use the command

ipfs swarm connect /ip4/x.x.x.x/tcp/4003/ipfs/QmXXXXXXXXXXXXXXXXXXX

I got this error :

Error: invalid peer address: invalid multiaddr, must begin with /

I don’t think I am doing something wrong, so what happens ?

What implementation and version are you using? Assuming this is go-ipfs, but worth asking.

The syntax looks correct and should work. Maybe something weird with your shell. What shell and OS are you using?

What platform are you on?
This seems like an issue in MSYS2/cygwin or similar linuxy environments for Windows, it seems that the /ip4/… multiaddr is converted to an absolute Windows filepath (C:\ip4\x.x.x.x\...).

Yeah, funny windows quirks I guess. Maybe it would work if wrapping the multiaddr with quotes like this:

ipfs swarm connect "/ip4/x.x.x.x/tcp/4003/ipfs/QmXXXXXXXXXXXXXXXXXXX"

I’m not sure this is an actual fix - the fix depends on the environment. MSYS2 needs setting an environment variable, and cygwin has some other solution.

You can always try:

echo /ip4/x.x.x.x/tcp/4003/ipfs/QmXXXXXXXXXXXXXXXXXXX | ipfs swarm connect
1 Like

I am using Windows 7 Pro and Git Bash.

I tried with “” and echo as suggested, both doesn’t work.

Edit: I just try in a Command Prompt, it works.

For reference, I found two related issues in ipfs/go-ipfs’s issue tracker: