ipfs-desktop icon indicating copy to clipboard operation
ipfs-desktop copied to clipboard

Linux: failed: listen tcp4 127.0.0.1:5001: bind: address already in use

Open ankurpython opened this issue 1 year ago • 7 comments

👉️ Please describe what you were doing when this error happened.

Specifications

  • OS: linux
  • IPFS Desktop Version: 0.22.0
  • Electron Version: 19.0.8
  • Chrome Version: 102.0.5005.148

Error

Error: Initializing daemon...
Kubo version: 0.14.0
Repo version: 12
System version: amd64/linux
Golang version: go1.18.3
2022/07/26 11:07:10 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.16.25.82/tcp/4001
Swarm listening on /ip4/172.17.0.1/tcp/4001
Swarm listening on /ip4/172.18.0.1/tcp/4001
Swarm listening on /ip4/172.19.0.1/tcp/4001
Swarm listening on /ip4/172.20.0.1/tcp/4001
Swarm listening on /ip4/172.21.0.1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/172.16.25.82/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: address already in use

    at errorTemplate (/opt/IPFS Desktop/resources/app.asar/src/daemon/migration-prompt.js:78:49)
    at loadWindow (/opt/IPFS Desktop/resources/app.asar/src/daemon/migration-prompt.js:115:26)
    at module.exports (/opt/IPFS Desktop/resources/app.asar/src/daemon/migration-prompt.js:120:3)
    a

ankurpython avatar Jul 26 '22 07:07 ankurpython

Hi @ankurpython,

It seems that IPFS Desktop failed to detect that something was already running on 5001, or it did and you chose not to change the ports. The error is clear, there is something running on port 5001. Do you perhaps know what it is?

I see you're on Linux, so if you run:

sudo netstat -tulpn | grep LISTEN | grep 5001

You can see whatever process is running on that port.

hacdias avatar Jul 29 '22 11:07 hacdias

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

github-actions[bot] avatar Aug 05 '22 00:08 github-actions[bot]

@lidel as per our discussion yesterday, I checked if the workflow for detecting the busy ports is working correctly and it seems to be working well on both macOS and Windows. Could you check if it works well on your Linux distro? It may be an issue with Linux in general, or a specific distribution.

hacdias avatar Aug 09 '22 11:08 hacdias

@hacdias how did you test?

I've shut down IPFS node and run unrelated HTTP server on port 5001 via

$ npx serve -l 5001 -d

Then I started ./ipfs-desktop-0.22.0-linux-x86_64.AppImage and it failed silently like this:

$ ./ipfs-desktop-0.22.0-linux-x86_64.AppImage
2022-08-15T16:49:43.774Z info: [meta] logs can be found on /home/lidel/.config/IPFS Desktop
2022-08-15T16:49:44.980Z info: [web ui] loading STARTED
2022-08-15T16:49:45.637Z info: [App] startup time - 2.0857269892692565 seconds
2022-08-15T16:49:45.639Z info: [web ui] loading FINISHED 0.6585600352287293s
2022-08-15T16:49:45.655Z info: [web ui] window ready
2022-08-15T16:49:45.656Z info: [web ui] navigate to /
Checking for update
2022-08-15T16:49:45.662Z info: [tray] starting
2022-08-15T16:49:45.717Z info: [tray] started
2022-08-15T16:49:45.718Z info: [ipfsd] start daemon STARTED
2022-08-15T16:49:45.796Z error: [ipfsd] start daemon HTTPError: <!DOCTYPE html><head> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/> <style> body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; cursor: default; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; } main, aside, section { display: flex; justify-content: center; align-items: center; flex-direction: column; } main { height: 100%; } aside { background: #000; flex-shrink: 1; padding: 30px 20px; } aside p { margin: 0; color: #999999; font-size: 14px; line-height: 24px; } aside a { color: #fff; text-decoration: none; } section span { font-size: 24px; font-weight: 500; display: block; border-bottom: 1px solid #EAEAEA; text-align: center; padding-bottom: 20px; width: 100px; } section p { font-size: 14px; font-weight: 400; } section span + p { margin: 20px 0 0 0; } @media (min-width: 768px) { section { height: 40px; flex-direction: row; } section span, section p { height: 100%; line-height: 40px; } section span { border-bottom: 0; border-right: 1px solid #EAEAEA; padding: 0 20px 0 0; width: auto; } section span + p { margin: 0; padding-left: 20px; } aside { padding: 50px 0; } aside p { max-width: 520px; text-align: center; } } </style></head><body> <main> <section> <span>404</span> <p>The requested path could not be found</p> </section> </main></body>
    at Object.errorHandler [as handleError] (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/node_modules/ipfs-http-client/cjs/src/lib/core.js:84:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Client.fetch (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/node_modules/ipfs-utils/src/http.js:145:9)
    at async Object.id (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/node_modules/ipfs-http-client/cjs/src/id.js:12:17)
    at async Daemon.start (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/node_modules/ipfsd-ctl/src/ipfsd-daemon.js:268:16)
    at async startIpfsWithLogs (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/src/daemon/daemon.js:144:5)
    at async module.exports (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/src/daemon/daemon.js:194:17)
    at async startIpfs (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/src/daemon/index.js:47:17)
    at async module.exports (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/src/daemon/index.js:115:3)
    at async run (/tmp/.mount_ipfs-d4EwGbi/resources/app.asar/src/index.js:84:5)
2022-08-15T16:49:45.815Z info: [automatic gc] enabled
2022-08-15T16:49:45.816Z info: [pubsub] disabled
2022-08-15T16:49:45.816Z info: [ipns over pubsub] disabled
2022-08-15T16:49:45.820Z info: [launch on startup] disabled
[31913:0815/184946.096041:ERROR:browser_main_loop.cc(271)] Gdk: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
Update for version 0.22.0 is not available (latest version: 0.22.0, downgrade is disallowed).
2022-08-15T16:49:46.651Z info: [updater] update not available
2022-08-15T16:50:16.169Z info: [web ui] window hidden
^C

No GUI informing user about port being taken, just webui in broken state:

2022-08-15-185014_1440x900_scrot

lidel avatar Aug 15 '22 16:08 lidel

@lidel that is exactly what I did (albeit I used caddy instead of npx serve). I followed your steps on macOS and Windows and it works as expected.

image

It clearly is a problem with Linux, but we need to understand if it is a general error, or specifically to certain distributions.

hacdias avatar Aug 16 '22 11:08 hacdias

Seems like we need to do some debugging in Linux

SgtPooki avatar Aug 22 '22 16:08 SgtPooki

@lidel is OOO this week so this will probably be delayed until he gets back

SgtPooki avatar Aug 22 '22 16:08 SgtPooki