[SOLVED] Cannot run daemon - listen tcp4 127.0.0.1:5001: bind: cannot assign requested address

Just downloaded a fresh ipfs binary and cannot run the daemon. No matter what port I try, I get a bind error.

$ wget https://dist.ipfs.io/go-ipfs/v0.4.17/go-ipfs_v0.4.17_linux-amd64.tar.gz
$ tar xvfz go-ipfs_v0.4.17_linux-amd64.tar.gz
$ cd go-ipfs
$ sudo ./install.sh

$ ipfs init
$ ipfs daemon
Initializing daemon...
Successfully raised file descriptor limit to 2048.

Swarm listening on /ip4/123.123.123.123/tcp/4001
Swarm listening on /ip4/172.17.0.1/tcp/4001
Swarm listening on /ip4/192.168.0.13/tcp/4001
Swarm listening on /ip4/192.168.122.1/tcp/4001
Swarm listening on /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001
Swarm listening on /ip6/2605:e000:6148:e000::5/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmU55qjfV8K9uZ9yD8MowcjnPMjU6U8ZFE659RCX3YM6TS
Swarm announcing /ip4/123.123.123.123/tcp/4001
Swarm announcing /ip4/172.17.0.1/tcp/4001
Swarm announcing /ip4/192.168.0.13/tcp/4001
Swarm announcing /ip4/192.168.122.1/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000::5/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: cannot assign requested address

$ lsof -i tcp:5001
$ sudo lsof -i tcp:5001
$ IPFS_REUSEPORT=false ipfs daemon             
Initializing daemon...                                                    
Successfully raised file descriptor limit to 2048.                            
Swarm listening on /ip4/123.123.123.123/tcp/4001                       
Swarm listening on /ip4/172.17.0.1/tcp/4001     
Swarm listening on /ip4/192.168.0.13/tcp/4001     
Swarm listening on /ip4/192.168.122.1/tcp/4001
Swarm listening on /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001
Swarm listening on /ip6/2605:e000:6148:e000::5/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmU55qjfV8K9uZ9yD8MowcjnPMjU6U8ZFE659RCX3YM6TS
Swarm announcing /ip4/123.123.123.123/tcp/4001
Swarm announcing /ip4/172.17.0.1/tcp/4001
Swarm announcing /ip4/192.168.0.13/tcp/4001
Swarm announcing /ip4/192.168.122.1/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000::5/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5002) failed: listen tcp4 127.0.0.1:5002: bind: cannot assign requested address
Received interrupt signal, shutting down...
(Hit ctrl-c again to force-shutdown the daemon.)

$ lsof -i tcp:3001
$ sudo lsof -i tcp:3001
$ ipfs config Addresses.API /ip4/127.0.0.1/tcp/3001
$ IPFS_REUSEPORT=false ipfs daemon
Initializing daemon...
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/123.123.123.123/tcp/4001
Swarm listening on /ip4/172.17.0.1/tcp/4001
Swarm listening on /ip4/192.168.0.13/tcp/4001
Swarm listening on /ip4/192.168.122.1/tcp/4001
Swarm listening on /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001
Swarm listening on /ip6/2605:e000:6148:e000::5/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmU55qjfV8K9uZ9yD8MowcjnPMjU6U8ZFE659RCX3YM6TS
Swarm announcing /ip4/123.123.123.123/tcp/4001
Swarm announcing /ip4/172.17.0.1/tcp/4001
Swarm announcing /ip4/192.168.0.13/tcp/4001
Swarm announcing /ip4/192.168.122.1/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000::5/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/3001) failed: listen tcp4 127.0.0.1:3001: bind: cannot assign requested address
Received interrupt signal, shutting down...

$ sudo firewall-cmd --zone=public --add-port=4001/tcp --permanent
success
$ sudo firewall-cmd --reload 
success
$ ipfs config Addresses.API /ip4/127.0.0.1/tcp/4001
$ IPFS_LOGGING=debug ipfs daemon                                                                                                                                                   
17:23:45.631 DEBUG   cmd/ipfs: config path is /home/adamhanna/.ipfs main.go:100                                                                                                       
Initializing daemon...                                                                                                                                                                
Successfully raised file descriptor limit to 2048.
...
17:23:46.512 DEBUG   addrutil: InterfaceAddresses: from manet:[/ip4/123.123.123.123 /ip4/192.168.0.13 /ip4/192.168.122.1 /ip4/172.17.0.1 /ip6/::1 /ip6/2605:e000:6148:e000::5 /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c /ip6/fe80::533a:e3eb:30d8:5a7f /ip6/fe80::42:dff:fe1b:3367] addr.go:121                                                                         
17:23:46.512 DEBUG   addrutil: InterfaceAddresses: usable:[/ip4/123.123.123.123 /ip4/192.168.0.13 /ip4/192.168.122.1 /ip4/172.17.0.1 /ip6/::1 /ip6/2605:e000:6148:e000::5 /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c] addr.go:133
17:23:46.512 DEBUG   addrutil: adding resolved addr:/ip4/0.0.0.0/tcp/4001 /ip4/123.123.123.123/tcp/4001 [/ip4/123.123.123.123/tcp/4001] addr.go:64                                   
17:23:46.512 DEBUG   addrutil: adding resolved addr:/ip4/0.0.0.0/tcp/4001 /ip4/192.168.0.13/tcp/4001 [/ip4/123.123.123.123/tcp/4001 /ip4/192.168.0.13/tcp/4001] addr.go:64           
17:23:46.512 DEBUG   addrutil: adding resolved addr:/ip4/0.0.0.0/tcp/4001 /ip4/192.168.122.1/tcp/4001 [/ip4/123.123.123.123/tcp/4001 /ip4/192.168.0.13/tcp/4001 /ip4/192.168.122.1/tcp/4001] addr.go:64
17:23:46.512 DEBUG   addrutil: adding resolved addr:/ip4/0.0.0.0/tcp/4001 /ip4/172.17.0.1/tcp/4001 [/ip4/123.123.123.123/tcp/4001 /ip4/192.168.0.13/tcp/4001 /ip4/192.168.122.1/tcp/4001 /ip4/172.17.0.1/tcp/4001] addr.go:64
17:23:46.512 DEBUG   addrutil: adding resolved addr:/ip6/::/tcp/4001 /ip6/::1/tcp/4001 [/ip6/::1/tcp/4001] addr.go:64                                                                
17:23:46.512 DEBUG   addrutil: adding resolved addr:/ip6/::/tcp/4001 /ip6/2605:e000:6148:e000::5/tcp/4001 [/ip6/::1/tcp/4001 /ip6/2605:e000:6148:e000::5/tcp/4001] addr.go:64        
17:23:46.512 DEBUG   addrutil: adding resolved addr:/ip6/::/tcp/4001 /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001 [/ip6/::1/tcp/4001 /ip6/2605:e000:6148:e000::5/tcp/4001 /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001] addr.go:64
17:23:46.512 DEBUG   addrutil: ResolveUnspecifiedAddresses:[/p2p-circuit/ipfs/QmU55qjfV8K9uZ9yD8MowcjnPMjU6U8ZFE659RCX3YM6TS /ip4/0.0.0.0/tcp/4001 /ip6/::/tcp/4001] [/ip4/123.123.123.123 /ip4/192.168.0.13 /ip4/192.168.122.1 /ip4/172.17.0.1 /ip6/::1 /ip6/2605:e000:6148:e000::5 /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c] [/p2p-circuit/ipfs/QmU55qjfV8K9uZ9yD8MowcjnPMjU6U8ZFE659RCX3YM6TS /ip4/123.123.123.123/tcp/4001 /ip4/192.168.0.13/tcp/4001 /ip4/192.168.122.1/tcp/4001 /ip4/172.17.0.1/tcp/4001 /ip6/::1/tcp/4001 /ip6/2605:e000:6148:e000::5/tcp/4001 /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001] addr.go:109
Swarm announcing /ip4/123.123.123.123/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000:576b:fe03:711b:4d0c/tcp/4001
Swarm announcing /ip6/2605:e000:6148:e000::5/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: cannot assign requested address                                                 
17:23:46.513 DEBUG       core: core is shutting down... core.go:598
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:82
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:82
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:85
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:82
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:82
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:85
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:85
17:23:46.513 DEBUG    bitswap: bitswap task worker shutting down... workers.go:82
17:23:46.513 DEBUG blockservi: blockservice is shutting down... blockservice.go:316
17:23:46.513 WARNI     swarm2: swarm listener accept error: process closing swarm_listen.go:77                                                                                       
17:23:46.513 WARNI     swarm2: swarm listener accept error: accept tcp 0.0.0.0:4001: use of closed network connection swarm_listen.go:77                                             
17:23:46.514 WARNI     swarm2: swarm listener accept error: accept tcp [::]:4001: use of closed network connection swarm_listen.go:77                                                
17:23:46.597 DEBUG      relay: Error testing relay hop: connection reset notify.go:41
Received interrupt signal, shutting down...
(Hit ctrl-c again to force-shutdown the daemon.)

I’m at a loss??? Thanks for any help!!

$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: Fedora
Description:    Fedora release 28 (Twenty Eight)
Release:        28
Codename:       TwentyEight

$ ipfs version
ipfs version 0.4.17

What’s the output of:

ss -n -l -A tcp -p | grep ':5001'

@stebalien

$ netstat | grep 5001
$ ss -n -l -A tcp -p | grep ':5001'

I’m almost positive this is some weird fedora thing because I’ve had no problem with IPFS on Ubuntu both 16 & 18.

Ok, I just tried on a fresh Fedora inside a virtual machine and the daemon started with no trouble. This is definitely some weird issue with my machine. I’ll try some fedora specific forums…

Ok, scratch this. I updated my Fedora, restarted and now everything is hunky dory… ugghhh

Ah, I know what happened. You’re loopback interface didn’t have an IPv4 address. If you take a look at the “swarm listening on” messages, you’ll see ::1 (IPv6 loopback) but not 127.0.0.1.

I actually have the same problem on macOS Mojave 10.14.2 and i didn’t understand how to fix it.
Could you help me in any way?
I’m desperate!

Can you post your exact error output?

What’s the output from

lsof -nP -i4TCP:4001,5001 | grep LISTEN