stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

Failed to establish a new connection

Open ztrbq opened this issue 2 years ago • 5 comments

I could perfectly run the webui yesterday until my windows get auto updated. It shows that my connection to 127.0.0.1:7860 is failed.

venv "E:\stable-diffusion-webui-master\venv\Scripts\Python.exe"
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]
Commit hash: <none>
Installing requirements for Web UI
Launching Web UI with arguments:
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [e6e8e1fc] from E:\stable-diffusion-webui-master\models\Stable-diffusion\model.ckpt
Loading VAE weights from: E:\stable-diffusion-webui-master\models\Stable-diffusion\model_nai.vae.pt
Applying cross attention optimization (Doggettx).
Model loaded.
Loaded a total of 0 textual inversion embeddings.
Traceback (most recent call last):
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\socks.py", line 787, in connect
    super(socksocket, self).connect(proxy_addr)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\contrib\socks.py", line 96, in _new_conn
    conn = socks.create_connection(
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\socks.py", line 209, in create_connection
    raise err
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\socks.py", line 199, in create_connection
    sock.connect((remote_host, remote_port))
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\socks.py", line 47, in wrapper
    return function(*args, **kwargs)
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\socks.py", line 800, in connect
    raise ProxyConnectionError(msg, error)
socks.ProxyConnectionError: Error connecting to SOCKS5 proxy 127.0.0.1:10808: [WinError 10061] 由于目标计算机积极拒绝, 无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "C:\Users\10798\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\10798\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\10798\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\10798\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1037, in _send_output
    self.send(msg)
  File "C:\Users\10798\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 975, in send
    self.connect()
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\connection.py", line 205, in connect
    conn = self._new_conn()
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\contrib\socks.py", line 127, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.contrib.socks.SOCKSConnection object at 0x000002717FD1B7C0>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: SOCKSHTTPConnectionPool(host='127.0.0.1', port=7860): Max retries exceeded with url: /startup-events (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSConnection object at 0x000002717FD1B7C0>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\stable-diffusion-webui-master\launch.py", line 169, in <module>
    start_webui()
  File "E:\stable-diffusion-webui-master\launch.py", line 164, in start_webui
    webui.webui()
  File "E:\stable-diffusion-webui-master\webui.py", line 105, in webui
    app, local_url, share_url = demo.launch(
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\gradio\blocks.py", line 1093, in launch
    requests.get(f"{self.local_url}startup-events")
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\requests\api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "E:\stable-diffusion-webui-master\venv\lib\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: SOCKSHTTPConnectionPool(host='127.0.0.1', port=7860): Max retries exceeded with url: /startup-events (Caused by NewConnectionError('<urllib3.contrib.socks.SOCKSConnection object at 0x000002717FD1B7C0>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))
请按任意键继续. . . 

And I tried using methods searched from Internet, but I could not open the port 7860. I'm wodering where can I change the port used by the webui.

ztrbq avatar Oct 15 '22 05:10 ztrbq

the same problem to me.

Tthod avatar Oct 15 '22 11:10 Tthod

the chinese characters above mean "No connection could be made because the target machine actively refused it".

Tthod avatar Oct 15 '22 11:10 Tthod

the same problem to me.

Did your windows get updated automatically recently? I guess it's due to the port problem, but I don't know how to fix it.

ztrbq avatar Oct 15 '22 14:10 ztrbq

I also encountered the same situation

DYS763 avatar Oct 16 '22 12:10 DYS763

Just try to delete the http and https proxy that you added to your environment variables before for lib downloading, or keep opening your proxy when running. I think that's because it's trying to connect the proxy port in environment variables, and you just shut down the port.

junqizeng avatar Oct 22 '22 15:10 junqizeng

Just try to delete the http and https proxy that you added to your environment variables before for lib downloading, or keep opening your proxy when running. I think that's because it's trying to connect the proxy port in environment variables, and you just shut down the port.

Thanks a lot! I just fixed it by deleting the proxy environment variables, and it works just fine.

ztrbq avatar Oct 23 '22 12:10 ztrbq

This issue happens to me again. I checked there was no proxy environment variables set in my machine. Can you be more specific about : "delete the http and https proxy that you added to your environment variables before for lib downloading". I don't remember I added any of those proxies...

chmlxj avatar Jan 08 '23 04:01 chmlxj

This issue happens to me again. I checked there was no proxy environment variables set in my machine. Can you be more specific about : "delete the http and https proxy that you added to your environment variables before for lib downloading". I don't remember I added any of those proxies...

If you encountered the same question, check your error report message. There should be one line like:

socks.ProxyConnectionError: Error connecting to SOCKS5 proxy 127.0.0.1:####: [WinError 10061] 由于目标计算机积极拒绝, 无法连接。

in which '####' represents the proxy port the program used, and should be the proxy port in the environment variables, but now this proxy port has been shut down(I guess). Recheck the system environment variables to ensure there is no proxy setting items or run git config --global --unset http.proxy and git config --global --unset https.proxy in the terminal. It's weird that if you have this problem, it means you have downloaded the lib successfullly, and to complete the download, you have used vpn(I assume you are Chinese) and changed the proxy port to your vpn port, but you just said you didn't change the port before, so actually I have no idea about your situation. Hope the answer will help you.

junqizeng avatar Jan 08 '23 11:01 junqizeng

Thanks for the response. Yes it looks like VPN messed around with my connection. After rebooting, it now works fine (VPN turned off)

chmlxj avatar Jan 08 '23 11:01 chmlxj

I had this same problem and it drove me nuts. I installed it and un-installed it and just could not get connected until one time, after double clicking the 'webui-user.bat' file, I left the cmd open and Voila! it connected. I didn't see anywhere in any of the online Stable Fusion setup websites, an instruction that said that you had to double click the 'webui-user.bat' every time you use it but aparently, that's the case. Everytime you want to use Stable Fusion you have to run the 'webui-user.bat' file and leave it open, you disconnect by closing the cmd. Hope this helps.

dazotk4u avatar Jul 21 '23 02:07 dazotk4u