Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Failed to proxy http://keep-backend:8080/pusher/auth Error: connect ECONNREFUSED 172.17.0.2:8080
at (Error: connect ECONNREFUSED 172.17.0.2:8080) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '172.17.0.2',
port: 8080
}

You must be logged in to vote

Replies: 1 comment · 5 replies

Comment options

这个错误是前端容器无法连接到后端服务 keep-backend:8080,具体是 /pusher/auth 这个端点的代理失败。

影响范围:

/pusher/auth 是用于 Pusher 实时通信的认证端点,负责验证用户是否有权限订阅租户专属的实时频道 [1]。当这个代理失败时:

  • 实时功能会失效:告警的实时推送更新将无法工作,页面不会自动刷新新告警数据
  • 前端 UI 不会报错:Pusher 连接失败只会在浏览器控制台打日志,不会在界面上显示错误提示 [2],所以用户可能不会立即察觉
  • 核心功能仍可用:手动刷新页面仍然可以获取数据,只是丢失了实时推送能力

常见原因和解决方法:

  1. 后端服务未启动或不可达:检查 keep-backend 容器是否正常运行,确认 8080 端口可达
  2. 网络/DNS 问题:从前端容器内测试能否解析并连接 keep-backend:8080
  3. 可选的绕过方案:设置前端的 API_URL_CLIENT 环境变量,让客户端直接连接后端,绕过 Next.js 代理层 [3]

简单来说,这个错误主要影响实时推送功能,不会导致整个平台不可用,但建议尽快排查后端连接问题。

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about keep with Dosu Add Dosu to your team

You must be logged in to vote
5 replies
@nsdsb123
Comment options

怎么设置API_URL_CLIENT变量

@dosubot
Comment options

API_URL_CLIENT 是浏览器端(客户端)用来访问后端 API 的地址,区别于 API_URL(前端服务器端内部访问后端的地址)[1]

Docker Compose 中设置方式:

docker-compose.yml 的前端服务中添加环境变量即可:

keep-frontend:
  image: us-central1-docker.pkg.dev/keephq/keep/keep-ui
  environment:
    - API_URL=http://keep-backend:8080        # 服务器端内部访问
    - API_URL_CLIENT=http://<你的服务器IP>:8080  # 浏览器端访问

设置什么值取决于你的部署方式:

  • 直接访问后端:设置为浏览器能访问到的后端地址,例如 http://<服务器IP或域名>:8080
  • 通过反向代理/ingress:设置为相对路径如 /v2 [2]
  • 默认值:如果不设置,默认是 /backend(相对路径)[3]

针对你之前遇到的 ECONNREFUSED 代理错误,设置 API_URL_CLIENT 为后端的可达地址可以让浏览器直接连接后端,绕过 Next.js 的代理层,从而避免该错误。

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about keep with Dosu Add Dosu to your team

@nsdsb123
Comment options

需要2个变量都配置吗,还是前端容器只配置API_URL_CLIENT就可以

@dosubot
Comment options

两个变量的作用不同,建议都配置

  • API_URL:前端服务器端(Next.js SSR)访问后端用的地址,比如 http://keep-backend:8080,这是容器内部通信地址 [1]
  • API_URL_CLIENT浏览器端访问后端用的地址,比如 http://<你的服务器IP>:8080,这是用户浏览器能访问到的地址 [2]

如果你只配置 API_URL_CLIENT 而不配 API_URL,前端服务器端的请求(如 SSR 渲染)可能会失败,因为 API_URL 没有默认值 [1]

反过来,如果只配 API_URL 不配 API_URL_CLIENT,客户端会默认用 /backend 相对路径通过 Next.js 代理访问后端 [3]——这正是你之前遇到 ECONNREFUSED 代理报错的情况。

所以推荐的配置是:

keep-frontend:
  environment:
    - API_URL=http://keep-backend:8080            # 容器内部通信
    - API_URL_CLIENT=http://<你的服务器IP>:8080    # 浏览器直连后端

这样服务器端走内部网络,浏览器端直连后端,就不再依赖 Next.js 代理层了。

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about keep Share Dosu with your team

@nsdsb123
Comment options

Failed to proxy http://keep-backend:8080/pusher/auth Error: connect ECONNREFUSED 172.17.0.2:8080
at (Error: connect ECONNREFUSED 172.17.0.2:8080) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '172.17.0.2',
port: 8080
}
Error: connect ECONNREFUSED 172.17.0.2:8080
at (Error: connect ECONNREFUSED 172.17.0.2:8080) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '172.17.0.2',
port: 8080
}
⨯ TypeError: fetch failed
at async l.request (.next/server/app/raw/workflows/[workflow_filename]/route.js:1:24299)
at async d (.next/server/app/(keep)/incidents/page.js:2:8307)
at async k (.next/server/app/(keep)/alerts/[id]/page.js:1:5844) {
digest: '1421236808',
[cause]: Error: connect ECONNREFUSED 172.17.0.2:8080
at (Error: connect ECONNREFUSED 172.17.0.2:8080) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '172.17.0.2',
port: 8080
}
}

我两个都配置了
- API_URL=
- API_URL_CLIENT
但前端容器内部还是报错,这个怎么定位到底是容器通信不了还是?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.