Open
Conversation
Fix: Proxy Handler Issue Causing 502 Bad Gateway Error Problem Users experiencing "HTTP Error 502: Bad Gateway" when connecting Nuke to ComfyUI server, even though ComfyUI is running correctly and accessible via browser. Root Cause The issue occurs when Nuke has system proxy settings configured (e.g., http://127.0.0.1:2080). The urllib2.urlopen() function automatically uses these proxy settings for all HTTP requests, including localhost connections. This causes the proxy server to attempt connecting to the ComfyUI server, resulting in a 502 Bad Gateway error. Solution Modified connection.py to bypass proxy settings for localhost connections by implementing ProxyHandler({}) for all HTTP requests. Changes Made Before: pythonresponse = urllib2.urlopen(request, timeout=30) After: python# Bypass proxy for localhost connections no_proxy_handler = urllib2.ProxyHandler({}) opener = urllib2.build_opener(no_proxy_handler) response = opener.open(request, timeout=30) Functions Updated GET() - for object_info and other API calls check_connection() - for connection verification POST() - for sending prompts and data Testing This fix was verified by testing direct urllib2 requests in Nuke Script Editor: With proxy: HTTP Error 502: Bad Gateway Without proxy: SUCCESS! Code: 200, Data length: 3,188,462 Compatibility This change maintains backward compatibility and doesn't affect users without proxy settings, while fixing the connection issue for users with system proxies configured.
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.
Fix: Proxy Handler Issue Causing 502 Bad Gateway Error Problem
Users experiencing "HTTP Error 502: Bad Gateway" when connecting Nuke to ComfyUI server, even though ComfyUI is running correctly and accessible via browser. Root Cause
The issue occurs when Nuke has system proxy settings configured (e.g., http://127.0.0.1:2080). The urllib2.urlopen() function automatically uses these proxy settings for all HTTP requests, including localhost connections. This causes the proxy server to attempt connecting to the ComfyUI server, resulting in a 502 Bad Gateway error. Solution
Modified connection.py to bypass proxy settings for localhost connections by implementing ProxyHandler({}) for all HTTP requests. Changes Made
Before:
pythonresponse = urllib2.urlopen(request, timeout=30) After:
python# Bypass proxy for localhost connections
no_proxy_handler = urllib2.ProxyHandler({})
opener = urllib2.build_opener(no_proxy_handler)
response = opener.open(request, timeout=30)
Functions Updated
GET() - for object_info and other API calls
check_connection() - for connection verification
POST() - for sending prompts and data
Testing
This fix was verified by testing direct urllib2 requests in Nuke Script Editor:
With proxy: HTTP Error 502: Bad Gateway
Without proxy: SUCCESS! Code: 200, Data length: 3,188,462
Compatibility
This change maintains backward compatibility and doesn't affect users without proxy settings, while fixing the connection issue for users with system proxies configured.