From 098ae2d2bd51e5fb921cf715519b9009525a8ba7 Mon Sep 17 00:00:00 2001 From: Danijel Date: Wed, 18 Mar 2026 01:11:02 +0100 Subject: [PATCH] fix: resolve EADDRINUSE and Traefik routing issues Remove host port binding from docker-compose to avoid port conflicts and add dokploy-network for proper Traefik discovery. Add graceful error handling for EADDRINUSE in HTTP server. Co-Authored-By: Claude Opus 4.6 (1M context) --- docker-compose.yml | 8 ++++++-- src/http-server.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 28cfe66..9eddea4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,21 @@ services: solidtime-mcp: build: . - ports: - - "${PORT:-3045}:3045" environment: - PORT=3045 # Optional: default SolidTime API URL for all sessions. # Clients can override this via the x-solidtime-api-url header. - SOLIDTIME_API_URL=${SOLIDTIME_API_URL:-https://app.solidtime.io} restart: unless-stopped + networks: + - dokploy-network healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3045/health"] interval: 30s timeout: 5s retries: 3 start_period: 10s + +networks: + dokploy-network: + external: true diff --git a/src/http-server.ts b/src/http-server.ts index 56544e7..0c7b3c8 100644 --- a/src/http-server.ts +++ b/src/http-server.ts @@ -172,6 +172,16 @@ const httpServer = http.createServer(async (req, res) => { } }); +httpServer.on("error", (err: NodeJS.ErrnoException) => { + if (err.code === "EADDRINUSE") { + console.error(`Error: Port ${PORT} is already in use.`); + console.error(`Either stop the existing process or set a different PORT environment variable.`); + } else { + console.error("Server error:", err); + } + process.exit(1); +}); + httpServer.listen(PORT, "0.0.0.0", () => { console.log(`SolidTime MCP HTTP server listening on port ${PORT}`); console.log(` MCP endpoint: http://0.0.0.0:${PORT}/mcp`);