Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occurred while trying to proxy request on Garden v0.12.50. #3667

Closed
eysi09 opened this issue Feb 3, 2023 · 1 comment · Fixed by #3690
Closed

Error occurred while trying to proxy request on Garden v0.12.50. #3667

eysi09 opened this issue Feb 3, 2023 · 1 comment · Fixed by #3690
Assignees

Comments

@eysi09
Copy link
Collaborator

eysi09 commented Feb 3, 2023

Bug

Current Behavior

Proxying a network request through a port forward created by Garden has been reported to fail with the following error after we upgraded to Node 18:

[HPM] Error occurred while trying to proxy request *** from localhost:XXXX to localhost:XXXX (ECONNREFUSED) 

This seems to happen when the client sending the network request uses Node's http-proxy-middleware and the target is localhost. Something like:

import { createProxyMiddleware } from "http-proxy-middleware"

const proxy = createProxyMiddlewareI({
  target: "localhost:8080" // <--- Target is localhost
})

Expected behavior

I would expect things to work as before, but maybe this is an issue in Node 18. Here's an SO thread that looks relevant and the suggestion is to use 127.0.0.1 instead of localhost.

So perhaps this is something that needs be handled by the user in the createProxyMiddleware function as opposed to by Garden.

Workaround

First, set the GARDEN_PROXY_DEFAULT_ADDRESS environment variable to 127.0.0.1. E.g.:

GARDEN_PROXY_DEFAULT_ADDRESS=127.0.0.1 garden deploy --dev

Then make sure to use 127.0.0.1 as opposed to localhost in the createProxyMiddleware function as suggested on StackOveflow.

Your environment

  • OS: macOS

garden version 0.12.50.

@Walther
Copy link
Contributor

Walther commented Feb 3, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants