Skip to content

Fix a self-hosted docker-compose.yaml bug caused by a recent firecrawl change#2252

Merged
mogery merged 1 commit intofirecrawl:mainfrom
th3w1zard1:patch-1
Oct 5, 2025
Merged

Fix a self-hosted docker-compose.yaml bug caused by a recent firecrawl change#2252
mogery merged 1 commit intofirecrawl:mainfrom
th3w1zard1:patch-1

Conversation

@th3w1zard1
Copy link
Copy Markdown
Contributor

@th3w1zard1 th3w1zard1 commented Oct 4, 2025

Add EXTRACT_WORKER_PORT to docker-compose environment

The Original Error

The Firecrawl container was failing to start with this error:

Error: listen EADDRINUSE: address already in use 0.0.0.0:3002
    at Server.setupListenHandle [as _listen2] (node:net:1940:16)

The API service was crashing because port 3002 was already occupied by another service inside the same container.

Root Cause Analysis

After extracting and analyzing the compiled JavaScript from inside the container, I discovered a port configuration mismatch:

  1. The extract-worker service (/app/dist/src/services/extract-worker.js) checks for the environment variable EXTRACT_WORKER_PORT:

    const workerPort = process.env.EXTRACT_WORKER_PORT || process.env.PORT || 3005;
  2. The variable wasn't set, so it fell back to the global PORT environment variable, which was set to 3002

  3. Race condition: The harness script spawns multiple services concurrently:

    • extract-worker started first and successfully bound to port 3002
    • Then the api service tried to start and also bind to port 3002
    • CRASH: EADDRINUSE error because the port was already taken
  4. Additional conflict discovered: The WORKER_PORT was set to 3005, but the harness script was also trying to configure extract-worker to use port 3005 via a different variable name (NUQ_WORKER_PORT), which wasn't being read by the code.

The Fix

Set unique ports for each service by adding the missing environment variable:

EXTRACT_WORKER_PORT: ${EXTRACT_WORKER_PORT:-3004}

Final port allocation:

  • API: 3002 (via PORT)
  • Extract Worker: 3004 (via EXTRACT_WORKER_PORT)
  • Queue Worker: 3005 (via WORKER_PORT)
  • NUQ Workers: 3006-3010 (via NUQ_WORKER_PORT)

This ensures each service inside the container binds to its own dedicated port without conflicts.

…l change

Add EXTRACT_WORKER_PORT to docker-compose environment
@th3w1zard1 th3w1zard1 requested a review from mogery as a code owner October 4, 2025 18:01
Copilot AI review requested due to automatic review settings October 4, 2025 18:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a Docker Compose configuration bug by adding the missing EXTRACT_WORKER_PORT environment variable that was required by a recent Firecrawl change.

  • Adds EXTRACT_WORKER_PORT environment variable with default port 3004

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@mogery mogery merged commit 7d4100b into firecrawl:main Oct 5, 2025
1 check passed
@th3w1zard1 th3w1zard1 deleted the patch-1 branch October 9, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants