简体   繁体   English

Docker 代理错误:无法从 localhost:3000 代理请求 /api/product/B002QYW8LW 到 http://localhost:5000

[英]Docker proxy error: Could not proxy request /api/product/B002QYW8LW from localhost:3000 to http://localhost:5000

I am trying to host my app through docker, but got this error:我正在尝试通过 docker 托管我的应用程序,但出现此错误:

client_1  | Proxy error: Could not proxy request /api/product/B002QYW8LW from localhost:3000 to http://localhost:5000.
client_1  | See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

With the below settings, it works for me locally.使用以下设置,它在本地适用于我。 I searched this through google and it seems to be relevent to the proxy settings.我通过谷歌搜索了这个,它似乎与代理设置有关。 Some people was able to set the proxy as an object, but it gaves me an error saying proxy needs to be a string.有些人能够将代理设置为 object,但它给了我一个错误,说代理需要是一个字符串。 That's why I decided to ask this question here again.这就是为什么我决定再次在这里问这个问题。 Can someone please help out?有人可以帮忙吗?

I have deleted irrelavent stuff in package.json to save space.为了节省空间,我删除了 package.json 中无关紧要的东西。

package.json for server: package.json 用于服务器:

{
  "name": "",
  "version": "",
  "description": "",
  "main": "src/server.js",
  "scripts": {
  },
  "repository": {
  },
  "author": "",
  "license": "",
  "bugs": {
  },
  "homepage": ""
  "dependencies": {},
  "devDependencies": {
  }
}

package.json for client: package.json 客户端:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
  },
  "scripts": {

  },
  "eslintConfig": {
  },
  "browserslist": {
    "production": [],
    "development": []
  },
  "proxy": "http://localhost:5000"
}

Containers:容器:

CONTAINER ID        IMAGE                    COMMAND             CREATED             STATUS              PORTS                    NAMES
e4b55b165c9a        productfetching_client   "npm start"         24 hours ago        Up 24 hours         0.0.0.0:3000->3000/tcp   productfetching_client_1
10581d34d189        productfetching_server   "node server.js"    24 hours ago        Up 24 hours         0.0.0.0:5000->5000/tcp   productfetching_server_1

Use the container name registered in docker-compose file as said in a comment or http://0.0.0.0:PORT instead which point to the local container network address, instead of localhost or 127.0.0.1 which point to your regular machine network.使用在 docker-compose 文件中注册的容器名称,如评论或http://0.0.0.0:PORT中所述,它指向本地容器网络地址,而不是 localhost 或 127.0.0.1 指向您的常规机器网络。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 出现错误:无法将请求/ api / plaid / accounts从localhost:3000代理到http:// localhost:5000 / - getting error : Could not proxy request /api/plaid/accounts from localhost:3000 to http://localhost:5000/ 代理错误:无法代理请求...从 localhost:3000 到 http://localhost:5000/ - Proxy error: Could not proxy request ... from localhost:3000 to http://localhost:5000/ 代理错误:无法代理请求/用户从 localhost:3000 到 http://localhost:5000/ - Proxy error: Could not proxy request /users from localhost:3000 to http://localhost:5000/ “React 代理错误:无法将请求 /api/ 从 localhost:3000 代理到 http://localhost:5000 (ECONNREFUSED)”?错误.. 没有在线解决方案 - "React Proxy error: Could not proxy request /api/ from localhost:3000 to http://localhost:5000 (ECONNREFUSED)'? Error.. No solution online 代理错误:无法代理请求 /api/house-listing 从 localhost:3000 到 http://localhost:5000? (ECONNRESET)、MERN - Proxy error: Could not proxy request /api/house-listing from localhost:3000 to http://localhost:5000? (ECONNRESET), MERN React 代理错误:无法代理请求 /api/ 从 localhost:3000 到 http://localhost:8000 (ECONNREFUSED) - React Proxy error: Could not proxy request /api/ from localhost:3000 to http://localhost:8000 (ECONNREFUSED) 代理错误:无法将请求/用户从localhost:3000代理到http:// localhost:3001 / - Proxy error: Could not proxy request /users from localhost:3000 to http://localhost:3001/ 代理错误:无法将请求 /adduser 从 localhost:3000 代理到 http://127.0.0.1/4000 - Proxy error: Could not proxy request /adduser from localhost:3000 to http://127.0.0.1/4000 将请求 localhost:3000/api/product 代理到 http://localhost:5000/ 时发生错误 - Error occurred while proxying request localhost:3000/api/product to http://localhost:5000/ ReactProxy 错误:无法将请求 /api 从 localhost:3000 代理到 http://192.168.0.8:4000。 在几次尝试后被 ECONNREFUSED 之前 --> ETIMEDOUT - ReactProxy error:Could not proxy request /api from localhost:3000 to http://192.168.0.8:4000. Before it was ECONNREFUSED after few tries --> ETIMEDOUT
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM