Skip to content

[Bug]: HTTP_PROXY is ignored #2102

@cloudcarver

Description

@cloudcarver

edit:
This approach can still fix the issue, note that you should also add the HTTPS_PROXY and HTTP_PROXY to $HOME/.config/systemd/user/openclaw-gateway.service:

For example:

[Service]
...
Environment="HTTP_PROXY=http://172.25.128.1:10810"
Environment="HTTPS_PROXY=http://172.25.128.1:10810"

original content:

clawdbot cannot use HTTP_PROXY and HTTPS_PROXY set in the environment variables, because the nature of the undici.

Workaround for folks who met the same issue:

Find the openclaw.mjs by running:

readlink -f "$(which openclaw)"

Then add the following code in openclaw.mjs after all import statements:

import { ProxyAgent, setGlobalDispatcher } from "undici";
const proxy =
  process.env.HTTPS_PROXY ||
  process.env.HTTP_PROXY;

if (proxy) {
  setGlobalDispatcher(new ProxyAgent(proxy));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions