Skip to content

Commit dab9d70

Browse files
committed
feat: improve health check diagnostics for port configuration issues
Enhanced error handling in test_agentic_mcp.py health check to help users identify common port configuration mistakes: - Clear distinction between HTTP server port (3000) and SurrealDB port (3004) - Detailed troubleshooting steps for connection failures - Example .env configuration showing correct port values - Helpful commands to verify server status and connectivity This addresses the common issue where users try to connect to the wrong port (e.g., 3004 SurrealDB instead of 3000 HTTP server) and get confusing 406 errors with no diagnostic information.
1 parent 768795f commit dab9d70

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

test_agentic_mcp.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,40 @@ async def run_http_tests():
322322
print(f" URL: {mcp_url}")
323323

324324
# Quick check if server is reachable
325+
print(f"\nChecking HTTP server health...")
326+
print(f" Endpoint: http://{HTTP_HOST}:{HTTP_PORT}/health")
327+
325328
try:
326329
import httpx
327330
async with httpx.AsyncClient() as client:
328-
response = await client.get(f"http://{HTTP_HOST}:{HTTP_PORT}/health", timeout=2.0)
331+
response = await client.get(
332+
f"http://{HTTP_HOST}:{HTTP_PORT}/health",
333+
timeout=2.0,
334+
follow_redirects=True
335+
)
329336
if response.status_code != 200:
330-
print(f"❌ Server health check failed: {response.status_code}")
337+
print(f"❌ Health check failed: HTTP {response.status_code}")
338+
print(f" Response: {response.text[:200] if response.text else 'empty'}")
339+
print(f"\n⚠️ Common port configuration issues:")
340+
print(f" - Port {HTTP_PORT} may be wrong")
341+
print(f" - Default HTTP server port: 3000")
342+
print(f" - SurrealDB port (NOT for HTTP): 3004")
343+
print(f" - Check CODEGRAPH_HTTP_PORT in .env file")
344+
print(f"\nStart CodeGraph HTTP server on correct port:")
345+
print(f" ./target/release/codegraph start http --host {HTTP_HOST} --port 3000")
331346
return 1
332347
print("✓ Server is reachable\n")
333348
except Exception as e:
334349
print(f"❌ Cannot reach server: {e}")
335-
print(f"\nStart server with:")
336-
print(f" ./target/release/codegraph start http --host {HTTP_HOST} --port {HTTP_PORT}")
350+
print(f"\n⚠️ Troubleshooting:")
351+
print(f" - Is the server running? Check: ps aux | grep codegraph")
352+
print(f" - Wrong port? Common mistake: using 3004 (SurrealDB) instead of 3000 (HTTP)")
353+
print(f" - Check firewall/network: curl http://{HTTP_HOST}:{HTTP_PORT}/health")
354+
print(f"\nExpected .env configuration:")
355+
print(f" CODEGRAPH_HTTP_HOST=127.0.0.1")
356+
print(f" CODEGRAPH_HTTP_PORT=3000 # HTTP server port (NOT SurrealDB 3004)")
357+
print(f"\nStart HTTP server with:")
358+
print(f" ./target/release/codegraph start http --host 127.0.0.1 --port 3000")
337359
return 1
338360

339361
results = []

0 commit comments

Comments
 (0)