Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

fix: gracefully handle port-in-use error on server startup (#13001)

Luke Mino-Altherr867b8d2408a8
diff --git a/server.py b/server.py
index 881da8e66..2f3b438bb 100644
--- a/server.py
+++ b/server.py
@@ -1,3 +1,4 @@
+import errno
import os
import sys
import asyncio
@@ -1245,7 +1246,13 @@ class PromptServer():
address = addr[0]
port = addr[1]
site = web.TCPSite(runner, address, port, ssl_context=ssl_ctx)
- await site.start()
+ try:
+ await site.start()
+ except OSError as e:
+ if e.errno == errno.EADDRINUSE:
+ logging.error(f"Port {port} is already in use on address {address}. Please close the other application or use a different port with --port.")
+ raise SystemExit(1)
+ raise
if not hasattr(self, 'address'):
self.address = address #TODO: remove this