feat: Add port availability check at startup#12459
Open
andygoodluck wants to merge 1 commit intoComfy-Org:masterfrom
Open
feat: Add port availability check at startup#12459andygoodluck wants to merge 1 commit intoComfy-Org:masterfrom
andygoodluck wants to merge 1 commit intoComfy-Org:masterfrom
Conversation
Adds port availability check before loading custom nodes to prevent port conflicts that only surface after lengthy custom node loading. Changes: - Added socket import for port checking - Added port availability check in main.py before creating PromptServer - Created port_check.py utility module with helper functions - Created test_port_check.py with comprehensive tests The check will: 1. Verify the server port is available before any heavy loading 2. Exit early with clear error message if port is in use 3. Provide helpful instructions for resolving the conflict Fixes Comfy-Org#8935 [Bounty]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds port availability check at the beginning of main.py to prevent port conflicts that only surface after lengthy custom node loading.
Problem
Users would start ComfyUI, wait for custom nodes to load (which can take a long time), and only then discover that the port was already in use:
This wastes time and provides a poor user experience.
Solution
Check port availability before loading custom nodes. If the port is in use, exit immediately with a clear error message.
Changes
1. main.py
socketimport2. port_check.py (new)
check_port_available(): Check if a port is availablecheck_server_port(): Check and exit if port is in use3. test_port_check.py (new)
Example Output
When port is available:
When port is in use:
Testing
All tests pass:
Related Issue
Fixes #8935