dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

[Bug] dx serve fails with "Address already in use" while port is actually free (MacOS)

Open weykon opened this issue 1 year ago • 2 comments

Environment

  • OS: MacOS
  • Dioxus Version: 0.6.3
  • dx CLI Version: 0.6.3
  • Rust Version: rustc 1.84.1 (e71f9a9a9 2025-01-27)

Issue Description

When running dx serve in a fullstack project, the server fails to start with an "Address already in use" error, even though the port is actually free and can be used by other servers.

Steps to Reproduce

  1. Create a new fullstack Dioxus project
  2. Run dx serve
  3. Get error: Failed to bind to 127.0.0.1:8080: Address already in use (os error 48)

Verification

I verified the port is actually free by:

  1. Running lsof -i :8080 shows no process using the port
  2. Successfully running simple-http-server -i -p 8080 on the same port
  3. The error persists even after:
    • Killing all related processes
    • Using different ports
    • Cleaning project (cargo clean)

Error Output

10:38:30 [server] listening on http://127.0.0.1:8081
10:38:29 [dev] Build completed successfully in 327ms, launching app! 💫
10:38:30 [server] thread 'main' panicked at crates/dx/src/main.rs:21:10:
10:38:30 [server] Failed to build server: Os { code: 48, kind: AddrInUse, message: "Address already in use" }

Additional Context

  • The issue occurs consistently across project restarts
  • Other web servers can successfully bind to the same port
  • No other processes are visibly using the port
  • System permissions appear correct (user owns all relevant directories)
  • The problem persists even with elevated permissions

Attempted Solutions

  1. Used different ports
  2. Cleaned project and cargo cache
  3. Checked and fixed file permissions
  4. Verified network access permissions
  5. Tested with simple-http-server to confirm port availability

Would appreciate any guidance on resolving this issue or what additional information might be helpful.

weykon avatar Feb 23 '25 03:02 weykon

If you are targeting dioxus desktop with fullstack, this might be the same issue as https://github.com/DioxusLabs/dioxus/issues/3689 which should be fixed by https://github.com/DioxusLabs/dioxus/pull/3693

ealmloff avatar Feb 24 '25 17:02 ealmloff

same bug, wait to resolve it

getong avatar Mar 30 '25 06:03 getong