convex-backend
convex-backend copied to clipboard
Crash at startup with "No ports free" from portpicker crate on server w/o IPV6 enabled
After docker compose up
Attaching to backend-1, dashboard-1
backend-1 | 2025-04-21T16:34:04.363056Z INFO convex_local_backend: Starting a Convex backend
backend-1 | 2025-04-21T16:34:04.363318Z INFO convex_local_backend: The self-host Convex backend will periodically communicate with a remote beacon server. This is to help Convex understand and improve the product. You can disable this telemetry by setting the --disable-beacon flag or the DISABLE_BEACON environment variable if you are self-hosting using the Docker image.
backend-1 | 2025-04-21T16:34:04.364572Z INFO convex_local_backend: Sentry is not enabled.
backend-1 | 2025-04-21T16:34:04.377105Z INFO local_backend::persistence: Connected to SQLite at /convex/data/db.sqlite3
backend-1 | 2025-04-21T16:34:04.379422Z INFO search::searcher::searcher: Searchlight starting, local_storage_path: /convex/data/tmp/.tmppQguyK max_size: 524.3 MB
backend-1 | 2025-04-21T16:34:04.402241Z INFO database::database: Bootstrapping indexes...
backend-1 | 2025-04-21T16:34:04.411470Z INFO indexing::backend_in_memory_indexes: Loading 73 enabled indexes
backend-1 | 2025-04-21T16:34:04.414225Z INFO database::database: Bootstrapping table metadata...
backend-1 | 2025-04-21T16:34:04.417261Z INFO database::subscription: Starting subscriptions worker
backend-1 | 2025-04-21T16:34:04.435212Z INFO indexing::backend_in_memory_indexes: Loading 73 enabled indexes
backend-1 | 2025-04-21T16:34:04.443551Z INFO database::committer: Loaded indexes into memory
backend-1 | 2025-04-21T16:34:04.445402Z INFO application: files storage path: "/convex/data/storage/files"
backend-1 | 2025-04-21T16:34:04.445727Z INFO application: modules storage path: "/convex/data/storage/modules"
backend-1 | 2025-04-21T16:34:04.445738Z INFO application: search storage path: "/convex/data/storage/search"
backend-1 | 2025-04-21T16:34:04.445746Z INFO application: exports storage path: "/convex/data/storage/exports"
backend-1 | 2025-04-21T16:34:04.445753Z INFO application: snapshot_imports storage path: "/convex/data/storage/snapshot_imports"
backend-1 | 2025-04-21T16:34:04.445757Z INFO database::database: Set search storage to LocalDirStorage { dir: "/convex/data/storage/search" }
backend-1 | 2025-04-21T16:34:04.445760Z INFO application: Local { dir: "/convex/data/storage" } storage is configured.
backend-1 | 2025-04-21T16:34:04.445773Z WARN cmd_util::env: Invalid value for ACTIONS_USER_TIMEOUT_SECS, falling back to 600: ParseIntError { kind: Empty }
backend-1 | 2025-04-21T16:34:04.464413Z INFO node_executor::local: Using local node executor. Source: /convex/data/tmp/.tmpLoULst/local.cjs
backend-1 | 2025-04-21T16:34:04.667478Z INFO database::committer: All clients have gone away, shutting down committer...
backend-1 | 2025-04-21T16:34:04.668133Z INFO search::fragmented_segment: Prefetcher shutting down!
backend-1 | 2025-04-21T16:34:04.668622Z ERROR common::errors: Caught error (RUST_BACKTRACE=1 RUST_LOG=info,common::errors=debug for full trace): No ports free
backend-1 | Error: No ports free
Same issue reported by another person in discord: https://discord.com/channels/1019350475847499849/1356355212255695101
I did a bit of debugging, looks like the culprit is portpicker crate, which was last updated 4 years ago. Error is coming from this line https://github.com/get-convex/convex-backend/blob/4593d3550071681cf3f422ac01be6e90ad6d0322/crates/node_executor/src/local.rs#L80
Which is added in this commit https://github.com/get-convex/convex-backend/commit/6be386a490909dda5b8fb1c12b6cca25326847c6 on March 8.
From discord: someone figured out
Yeah for this issue I was having problems with the port picker library as I was running on a server without IPV6 enabled. I was able to get IPV6 enabled on the server so it can appropriately check for free ports even though that doesn’t seem necessary. Better error handling around this would be helpful—the whole library could probably be inlined. Although I guess not a lot of people assume you’re running a server without IPV6, since that’s pretty standard now.
We'd take a PR to improve the error messages in this scenario. Agreed that "no ports free" isn't particularly useful.
So far what I see there is actually no requirement for ipv6 for the application to work. It's just a bug in portpicker that it fails when ipv6 isn't enabled. The proper fix IMO would be to ditch abandoned portpicker and add the functionality in this project with ipv6 port check disabled when system ipv6 is disabled.
Getting Convex working in ipv4 and maintaining that isn't a priority for us internally, but if a community member wants to put in the legwork to send a PR that gets things working in both ipv4/ipv6 environments, we'd take it