[GH-ISSUE #3841] [BUG]: Proxy Connection Issues: AnythingLLM Fails with HTTP/SOCKS5 Proxies Due to Missing Explicit Proxy Agent Handling #2452

Closed
opened 2026-02-22 18:29:44 -05:00 by yindo · 2 comments
Owner

Originally created by @Nankawa-Chie on GitHub (May 17, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3841

How are you running AnythingLLM?

AnythingLLM desktop app

What happened?

When AnythingLLM is configured to use an external LLM provider (e.g., OpenAI, Gemini) and the system is behind a proxy (HTTP or SOCKS5), it consistently fails with a "Connection error". This occurs even when HTTP_PROXY, HTTPS_PROXY, and NODE_TLS_REJECT_UNAUTHORIZED=0 environment variables are correctly set.

The application's logs indicate that it attempts to connect directly to the LLM provider's IP address, bypassing the configured proxy. For instance, when Gemini is selected, errors sometimes originate from an OpenAI.makeRequest function, and when trying to list models for any provider, a generic "Connection error" occurs.

Further investigation using standalone Node.js scripts reveals the following:

  1. Node.js's native https.request module fails to connect through the proxy (both HTTP and SOCKS5 as specified in HTTPS_PROXY environment variable), resulting in ETIMEDOUT errors and attempts to connect to destination IPs directly.
  2. However, when using specialized proxy agent libraries like https-proxy-agent (for HTTP proxies) or socks-proxy-agent (for SOCKS5 proxies) within the same Node.js environment and with the same proxy settings, network connections to external services (e.g., api.openai.com) succeed (returning HTTP 200 or 401).

This strongly suggests that AnythingLLM, or the underlying Node.js HTTP/HTTPS clients it uses (possibly the native ones or libraries like the openai npm package without proper agent configuration), are not correctly utilizing the proxy settings in this specific Windows environment without an explicit proxy agent. The application needs to leverage a proxy agent library to reliably connect through proxies in such environments.

Are there known steps to reproduce?

  1. Set up a Windows environment that requires a proxy (either HTTP or SOCKS5) to access the internet. For testing, a local proxy like V2RayN listening on 127.0.0.1:10808 can be used.
  2. Configure the following environment variables in the command prompt before launching AnythingLLM:
    • For HTTP proxy:
      set HTTP_PROXY=http://127.0.0.1:10808
      set HTTPS_PROXY=http://127.0.0.1:10808
      set NODE_TLS_REJECT_UNAUTHORIZED=0
      
    • Or for SOCKS5 proxy:
      set HTTP_PROXY=socks5://127.0.0.1:10808
      set HTTPS_PROXY=socks5://127.0.0.1:10808
      set NODE_TLS_REJECT_UNAUTHORIZED=0
      
  3. Launch AnythingLLM (desktop application) from the same command prompt.
  4. Attempt to configure an external LLM provider (e.g., OpenAI or Gemini) with a valid API key.
  5. Observe that AnythingLLM fails to connect:
    • It might fail to fetch the list of available models.
    • If model selection is possible, attempting to chat will result in a "Connection error".
  6. Verification:
    • Run a simple Node.js script using the native https.request to an external HTTPS endpoint (e.g., https://api.openai.com/v1/models) with the same environment variables. This script will likely fail with ETIMEDOUT and show direct IP connection attempts.
    • Run a modified Node.js script that uses https-proxy-agent (for HTTP proxy) or socks-proxy-agent (for SOCKS5 proxy) to make the same request. This script will likely succeed.

Expected Behavior:
AnythingLLM should successfully connect to external LLM providers through the proxy specified in the HTTP_PROXY/HTTPS_PROXY environment variables.

Actual Behavior:
AnythingLLM fails to use the proxy, resulting in connection errors.

Suggestion for Resolution:
Integrate a robust proxy-handling mechanism, potentially using libraries like https-proxy-agent or socks-proxy-agent (or ensure any HTTP client library used, like axios or the openai package, is configured to use these agents when proxy environment variables are set). This will improve compatibility for users in environments where Node.js's native proxy handling is insufficient.

Originally created by @Nankawa-Chie on GitHub (May 17, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3841 ### How are you running AnythingLLM? AnythingLLM desktop app ### What happened? When AnythingLLM is configured to use an external LLM provider (e.g., OpenAI, Gemini) and the system is behind a proxy (HTTP or SOCKS5), it consistently fails with a "Connection error". This occurs even when `HTTP_PROXY`, `HTTPS_PROXY`, and `NODE_TLS_REJECT_UNAUTHORIZED=0` environment variables are correctly set. The application's logs indicate that it attempts to connect directly to the LLM provider's IP address, bypassing the configured proxy. For instance, when Gemini is selected, errors sometimes originate from an `OpenAI.makeRequest` function, and when trying to list models for any provider, a generic "Connection error" occurs. Further investigation using standalone Node.js scripts reveals the following: 1. Node.js's native `https.request` module fails to connect through the proxy (both HTTP and SOCKS5 as specified in `HTTPS_PROXY` environment variable), resulting in `ETIMEDOUT` errors and attempts to connect to destination IPs directly. 2. However, when using specialized proxy agent libraries like `https-proxy-agent` (for HTTP proxies) or `socks-proxy-agent` (for SOCKS5 proxies) within the same Node.js environment and with the same proxy settings, network connections to external services (e.g., `api.openai.com`) succeed (returning HTTP 200 or 401). This strongly suggests that AnythingLLM, or the underlying Node.js HTTP/HTTPS clients it uses (possibly the native ones or libraries like the `openai` npm package without proper agent configuration), are not correctly utilizing the proxy settings in this specific Windows environment without an explicit proxy agent. The application needs to leverage a proxy agent library to reliably connect through proxies in such environments. ### Are there known steps to reproduce? 1. Set up a Windows environment that requires a proxy (either HTTP or SOCKS5) to access the internet. For testing, a local proxy like V2RayN listening on `127.0.0.1:10808` can be used. 2. Configure the following environment variables in the command prompt before launching AnythingLLM: * For HTTP proxy: ```cmd set HTTP_PROXY=http://127.0.0.1:10808 set HTTPS_PROXY=http://127.0.0.1:10808 set NODE_TLS_REJECT_UNAUTHORIZED=0 ``` * Or for SOCKS5 proxy: ```cmd set HTTP_PROXY=socks5://127.0.0.1:10808 set HTTPS_PROXY=socks5://127.0.0.1:10808 set NODE_TLS_REJECT_UNAUTHORIZED=0 ``` 3. Launch AnythingLLM (desktop application) from the same command prompt. 4. Attempt to configure an external LLM provider (e.g., OpenAI or Gemini) with a valid API key. 5. Observe that AnythingLLM fails to connect: * It might fail to fetch the list of available models. * If model selection is possible, attempting to chat will result in a "Connection error". 6. **Verification:** * Run a simple Node.js script using the native `https.request` to an external HTTPS endpoint (e.g., `https://api.openai.com/v1/models`) with the same environment variables. This script will likely fail with `ETIMEDOUT` and show direct IP connection attempts. * Run a modified Node.js script that uses `https-proxy-agent` (for HTTP proxy) or `socks-proxy-agent` (for SOCKS5 proxy) to make the same request. This script will likely succeed. **Expected Behavior:** AnythingLLM should successfully connect to external LLM providers through the proxy specified in the `HTTP_PROXY`/`HTTPS_PROXY` environment variables. **Actual Behavior:** AnythingLLM fails to use the proxy, resulting in connection errors. **Suggestion for Resolution:** Integrate a robust proxy-handling mechanism, potentially using libraries like `https-proxy-agent` or `socks-proxy-agent` (or ensure any HTTP client library used, like `axios` or the `openai` package, is configured to use these agents when proxy environment variables are set). This will improve compatibility for users in environments where Node.js's native proxy handling is insufficient.
yindo added the possible bug label 2026-02-22 18:29:44 -05:00
yindo closed this issue 2026-02-22 18:29:44 -05:00
Author
Owner

@oscar6922 commented on GitHub (Oct 31, 2025):

Dear Nankawa-Chie,

We run into the same issue that you describe above. You have marked this as "completed". What did you do to solve the issue? We are on version v1.9.0

Thank you!

@oscar6922 commented on GitHub (Oct 31, 2025): Dear Nankawa-Chie, We run into the same issue that you describe above. You have marked this as "completed". What did you do to solve the issue? We are on version v1.9.0 Thank you!
yindo changed title from [BUG]: Proxy Connection Issues: AnythingLLM Fails with HTTP/SOCKS5 Proxies Due to Missing Explicit Proxy Agent Handling to [GH-ISSUE #3841] [BUG]: Proxy Connection Issues: AnythingLLM Fails with HTTP/SOCKS5 Proxies Due to Missing Explicit Proxy Agent Handling 2026-06-05 14:46:39 -04:00
Author
Owner

@joaocc commented on GitHub (May 26, 2026):

This seems to be duplicated from https://github.com/Mintplex-Labs/anything-llm/issues/4868 but there doesn't seem to be a solution for this.

<!-- gh-comment-id:4543190053 --> @joaocc commented on GitHub (May 26, 2026): This seems to be duplicated from https://github.com/Mintplex-Labs/anything-llm/issues/4868 but there doesn't seem to be a solution for this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2452