You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HPM] Error occurred while trying to proxy request #171
Hello this issue more about clarification, i have regular proxy to redirect requests to avoid CORS
however also we need to be connected to customer VPN, and sometimes we have proxy worked and sometimes we have next
[HPM] Error occurred while trying to proxy request /login from localhost:4200 to <TARGET> (ETIMEDOUT) (https://nodejs.org/api/errors.html#errors_common_system_errors)
but without proxy TARGET endpoint works well always so we've decided that it can be problem with proxying some, could you please clarify about it?
Don't see anything unusual in your configuration.
Understand your <TARGET> is masked in the example. Can you provide an anonymized <TARGET> example? Since you can have many variations for target.
Wondering if webpack-dev-server might cause the issue...
Can you try out a simplified setup with just express + http-proxy-middleware and see if the issue persists?
@chimurai According to my little investigation this is scenario with response delay from vpn connection.
When i do request it goes throw proxy to nginx (in our current solution), if i'm not wrong HPM receives success response from nginx so HPM doesn't fails.
nging waits for response from server (which is under vpn).
It can be long response, even for 2 minutes
before using nginx
I've tried option.proxyTimeout however it didn't help, migth i've made something whrong, but you can try to reproduce it with vpn and long responce emulation.
I get the error ([HPM] Error occurred while trying to proxy request /api/v1/xxx from localhost:3000 to http://xxx.com (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)) when I post a body.
Solved it by remove the express body-parser middleware before HPM.
Mybe help for someone.
Reacted by sosohime, Ilmir Shaikhutdinov, vrpruthvi, Jeremy Stocker, 撼天震地, Nick, csmarrero, Roger Beaman, Jeff Laflamme, Cliff Meyers and 75 more
Reacted by alen, sosohime, baudelee, Christian Nikkanen, Daniel Lewis BSc (Hons), Dmitry Smirnov, henry, Mikhail Pelewin, Slimani Mohammed, Rafael Souza and 10 more
Reacted by Josh C, Rob.Bulmer, Christian Cabauatan, Dima Utkin, ixcviw7bw, Jani, Daniel Lewis BSc (Hons), Sehwan Kim, Dmitry Smirnov, Akın Tekeoğlu and 16 more
Reacted by Slimani Mohammed, Jens Kjær Schødt, Abhishek Gupta, Rafael Souza, Satyam Tiwari, fangyi, Arthur Soares, sanxwang, omid, Janka Uryga and 7 more
Reacted by Slimani Mohammed, Rafael Souza, Satyam Tiwari, fangyi, sanxwang, Shawn Yang, Foxxo, Abdul Rauf and Pierre_T
Reacted by Slimani Mohammed, Rafael Souza, Sérgio A. Kopplin, fangyi, Foxxo, Abdul Rauf, Naeem Hussain, jawahar10 and Sang Nguyen Van
@wmzy I tried your solution (removed body-parser from the express app) and it worked, but I don't understand how the app is still working without body-parser. Isn't it required with express v.4+?(I was testing with express version 4.12.2)
The body-parser consume the http request body stream before the HPM read it.
body-parser is optional for express. If your app need it, place it after HPM.
Reacted by Nelson Omuto, Ritchie, Dmitriy Davydov, Li Poh, Sebastian Sędzik, Daniel Norio, Joseph Khan, Teaseung Kim, Fabien Warniez, amper-fb and 8 more
Reacted by The Mist, max d, Fabien Warniez, Gladius and Alexey Formin
Tired many configurations, mine is quite unique. I use the hosts files to rewrite my domains from the typical 127.0.0.1, [::1], or localhost. I also have a build directory that will, more-or-less, generate a unique site based on the host path. I didn't need to change my host file but will include it as including ipv6 is becoming a necessity. While the initial 'target' will be replaced every time it seems it may need to be in the same IPV-Protocol as ... well speculation aside removing localhost, [::1], and keeping 127.0.0.1 did the job for me. I would experiment with this discovery
➜ web git:(richard) ✗ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost local.example.org local.example2.com local.example.com local.example.gg local.dropingaming.co
255.255.255.255 broadcasthost
::1 localhost local.example.com local.example.com local.example.gg
Error occured while trying to proxy to: localhost:8082/schedule
In my browser. Not sure what the difference is :(
Edit: Ok, I realized I'm dumb. I'm running webpack-dev-server in a docker/kubernetes container, which means I don't want localhost nor port 8080. I need to use the internal hostname and port #. e.g.
Hi everyone, @yuankui I have the following setup in my code , everything works fine when i am on LAN , but it gives me 504 gateway time out error when i am on wifi . any suggestions
Activity
chimurai commentedon Jun 15, 2017
Don't see anything unusual in your configuration.
Understand your
<TARGET>is masked in the example. Can you provide an anonymized<TARGET>example? Since you can have many variations fortarget.Wondering if webpack-dev-server might cause the issue...
Can you try out a simplified setup with just
express+http-proxy-middlewareand see if the issue persists?https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md#express
djleonskennedy commentedon Jun 15, 2017
@chimurai Thank you for answer,
TARGETis internal customer url that works if access to it directly (without proxy)I'll try
express + http-proxy-middleware, and let you know as fast as i'll tryThank you
djleonskennedy commentedon Jun 19, 2017
@chimurai problem with local environment
chimurai commentedon Jun 19, 2017
Glad you've found an answer.
Care to share the cause and solution?
djleonskennedy commentedon Jun 19, 2017
@chimurai We've solved with using
nginxlocalhost:4200 (angular CLI) -> http-proxy-middleware -> ngnix -> (vpn)
AndriiDidkivsky commentedon Jun 19, 2017
Yeah, we've not configured our application just with http-proxy-middleware
So it's perhaps your issue.
It would be great to solve that problem just with one proxy :)
chimurai commentedon Jun 19, 2017
Using multiple proxies is indeed not ideal.
Can you provide an isolated example in which this issue is reproducible?
I'll be happy to dive into it and see if it is an issue with HPM.
AndriiDidkivsky commentedon Jun 19, 2017
You can go to our office and we'll show you. :)
There is only one case to reproduce. VPN connection to environment and proxy server to some API.
Do you know any services where we can use vpn + proxy to provide an isolated example ?
I might try to create an small example for you in this case.
chimurai commentedon Jun 21, 2017
Not aware of any currently.
Would be nice if you could spend some small effort to debug the issue.
djleonskennedy commentedon Jun 29, 2017
@chimurai According to my little investigation this is scenario with response delay from vpn connection.
When i do request it goes throw proxy to
nginx(in our current solution), if i'm not wrongHPMreceives success response from nginx soHPMdoesn't fails.ngingwaits for response from server (which is under vpn).It can be long response, even for 2 minutes
before using
nginxI've tried
option.proxyTimeouthowever it didn't help, migth i've made something whrong, but you can try to reproduce it with vpn and long responce emulation.Regards
wmzy commentedon Jan 9, 2018
I get the error ([HPM] Error occurred while trying to proxy request /api/v1/xxx from localhost:3000 to http://xxx.com (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)) when I post a body.
Solved it by remove the express body-parser middleware before HPM.
Mybe help for someone.
yuankui commentedon Nov 15, 2018
In my case I add a header in the client(proxy), then solves it
may this will help you
lkaratun commentedon Apr 3, 2019
@wmzy I tried your solution (removed body-parser from the express app) and it worked, but I don't understand how the app is still working without
body-parser. Isn't it required with express v.4+?(I was testing with express version 4.12.2)wmzy commentedon Apr 4, 2019
The
body-parserconsume the http request body stream before theHPMread it.body-parseris optional forexpress. If your app need it, place it afterHPM.22 remaining items
philip-nicholls commentedon Sep 14, 2021
For me, adding:
changeOrigin: truefixed the proxying for me. My origin just kills the connection if the hostname is incorrect.
asnow73 commentedon Sep 15, 2021
In my case changing version of wsl (windows subsystem for linux) helps. With version 2 error disappered
SuperTapir commentedon Jan 17, 2022
OMG, thank you. It works.
mdelorimier commentedon Jan 28, 2022
Having an issue similar to this one our solution was to allow the port with SELinux
semanage port -a -t http_port_t -p tcp 3005https://blog.ijun.org/2014/11/selinux-allow-httpd-to-connect-to.html
supriome commentedon Mar 26, 2022
Thank you very much. It works.
RichardTMiles commentedon Apr 20, 2022
Tired many configurations, mine is quite unique. I use the hosts files to rewrite my domains from the typical 127.0.0.1, [::1], or localhost. I also have a build directory that will, more-or-less, generate a unique site based on the host path. I didn't need to change my host file but will include it as including ipv6 is becoming a necessity. While the initial 'target' will be replaced every time it seems it may need to be in the same IPV-Protocol as ... well speculation aside removing localhost, [::1], and keeping
127.0.0.1did the job for me. I would experiment with this discovery__UPDATE
netlify/create-react-app-lambda#19
restart your computer^ sounds silly works often
fatemeh-web commentedon May 4, 2022
i still have problem and i did everything but not working yet. and this is my configeration: my front port is 5000 and backend is 3000:80
callumgare commentedon Jun 2, 2022
For anyone running into this issue with Next.js you should be able to disable body-parser by adding
bodyParser: falseto the route config. E.g:mnpenner commentedon Sep 11, 2022
I tried #171 (comment), modified the example to:
Then hit http://localhost:3000 in my browser. It proxies the request perfectly fine.
With webpack 4.x, I have:
But I keep getting
In my terminal, or
In my browser. Not sure what the difference is :(
Edit: Ok, I realized I'm dumb. I'm running webpack-dev-server in a docker/kubernetes container, which means I don't want localhost nor port 8080. I need to use the internal hostname and port #. e.g.
ObaidAshiq commentedon Jan 24, 2024
For me my localhost works but not the production
I have 3 ports
1 st is for prozy
2nd doesnt work with proxy
3rd works like a charm
biletboh commentedon Feb 13, 2024
If you use nestjs, you can disable body parser like this:
TuKun33 commentedon Feb 18, 2024
如果你是https协议,检查一下ssl证书是否过期
tanujwg commentedon Mar 2, 2024
I am having same issue, anyone has any solution