chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.7k stars 834 forks source link

504 errors require computer restart #785

Closed RichardTMiles closed 2 years ago

RichardTMiles commented 2 years ago

Checks

Describe the bug (be clear and concise)

Firstly, Thank You!

Frequently my team requires restarting our computer to solve all our requests resolving to a 504. We have been following this thread which seems to accurately describe and diagnose the problem. I have a very detailed post of our latest findings and figured belongs here.

https://github.com/netlify/create-react-app-lambda/issues/19

This could very well be a OS/System issue, but I want your eyes on it /// see if you've seen it.

Best, Richard Miles

Step-by-step reproduction instructions

https://github.com/netlify/create-react-app-lambda/issues/19

Expected behavior (be clear and concise)

Non 504 errors.

How is http-proxy-middleware used in your project?

All request proxy to apache Wordpress.

What http-proxy-middleware configuration are you using?

simple routing.

What OS/version and node/version are you seeing the problem?

Monterey 12.2.1

Additional context (optional)

No response

RichardTMiles commented 2 years ago

https://github.com/chimurai/http-proxy-middleware/blob/master/README.md#nodejs-17-econnrefused-issue-with-ipv6-and-localhost-705

RichardTMiles commented 2 years ago

https://github.com/chimurai/http-proxy-middleware/issues/705

chimurai commented 2 years ago

Is your issue related to node17+ new dns lookup behaviour for localhost?

RichardTMiles commented 2 years ago

In react v18 the behavior has changed to allow DNS to resolve ipv4 or ipv6 in any order, ie use first provided by OS. With macOs 12.4 (21F79) I believe ipv6 is the default regardless of order provided in your hosts file. This may have more or less been random, chosen at restart, but the links provided go into this in more detail.

My apache configuration was not setup to receive traffic from ipv6. Adding the listener as follows and restarting apache fixed this issue without a restart.

httpd.conf

Listen 0.0.0.0:8080
Listen [::1]:8080

This solves // completes my research. Hopefully this info I've added here will help the next person. :)

chimurai commented 2 years ago

Thanks for getting back and sharing your research and solution! 🚀