Error occured while trying to proxy to: localhost:3000/hello
cezarneaga opened this issue · comments
i cannot seem to get it to work.
clean install, both with npm and yarn.
bad gateway 504 on all api calls
[HPM] Error occurred while trying to proxy request /hello from localhost:3000 to http://localhost:9000/ (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
node 10.15.0
hi,
sorry i havent seen this error before. i'm on node 10.13.0 myself and it works fine. do you have any other environment/browser/OS situations that might be relevant to this case?
am using nvm. have some other versions of node. but nothing else out of the ordinary
no clue at all, sorry. i recommend you start with create-react-app, make sure that works, and then add netlify-lambda on top. i’ll record a video for you
kinda the same here: gatsbyjs/gatsby#10985
responded on that issue accordingly. as long as the error isnt the same (this one is ECONNRESET) i consider this a different issue
I followed the video too, and i get the same error :(
Also on lts:carbon
This is so weird.
this is gonna sound really stupid but have you tried restarting your computer
note that the proxy we set up is ONLY for proxying from localhost:3000/.netlify/functions/hello
(where your react app is running) to localhost:9000/.netlify/functions/hello
(where your lambda server is running). localhost:3000/hello
is not supported.
i know. clicking on the button returns the 504
not accessing the /hello page
happy to reopen the issue if you wanna share a repro, i have no idea how else to help you.
Resurrecting an old thread to hopefully help someone out 💀.
Maybe you have a collision on port 9000. try running netlify-lambda somewhere else
ie. netlify-lambda serve src/lambda-src/ --port 9010
don't forget to update your proxy config to match.
I also wanted to add that I was getting the same 504 when I was trying to hit my netlify function. Configuring http-proxy-middleware
did not work for me, but adding "proxy": "http://localhost:8888/",
to my package.json
file did. My React app is running on http://localhost:3000/
and my Netlify functions running on http://localhost:8888/
.
at this point i really recommend using netlify dev so you dont have to configure all this gunk :)
My next project I will definitely start out using create-react-app-lambda
. I'd added netlify-lambda
to an existing React project and was comparing the way create-react-app-lambda
was set up to try to get mine going. I'm new to Netlify and React but I finally got it going.
Happened to me when I forgot to put http://
but instead just typed localhost:9000
Error occurred while trying to proxy request /api/video/thumbnail from localhost:3000 to http://localhost:5001/
Sucks
not sure if this is relevant but i had the same error all of a sudden.
After some debugging a silent error in a switch statement on a specific route handle seems to have fixed this for me.
this is gonna sound really stupid but have you tried restarting your computer
My team faces this issues somewhat frequently and a restart will (seem to*) solve it.
I face this issue when I'm trying to proxy request from localhost:XXXX to localhost:YYYY
Okay so I found some very strange behavior this past week regarding this issue. At this point I assume everyone having this issue is running the local dev env on MAC OS? I believe this to be a system level issue, but cannot say for certain.
- My etc hosts file contain multiple domains pointed for
- When the 504 - starts
-
I can use another domain in the list in the
/etc/hosts
file and the request will successfully be made toAPACH
!!!! -
Pull out Wireshark and all I see is ack on the loopback
I'm no networking expert so I'm pretty much done diving in at the moment.. hopefully YOU can take this research further! lol
// happy hacking
Aight so I'm becoming a networking expert after this latest update; three restarts and 504 each time. I've learned to reduce my Wireshark parameter input to just Loopback: Io0
, start, then filter using tcp.port == 8080
(the port my apache is running). From top to bottom we immediately see a grey then red status indication (lines 1 & 2 respectively). From here to the next red line (No. 271) would indicate our error 504
. I changed the domain in my browser to another in my hosts also listed under 127.0.0.1
. The green lines (No 781, 807, 869, 875) do represent successful interprocess communication on this attempt. This obviously leads us to note the Source and Destination ::1 vs 127.0.0.1. This is our cause.
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. :)
I've been reading through the thread and none of the solutions offered so far have fixed this issue for me — did anyone else come across another solution for this? I'm trying to proxy localhost:8081 to localhost:4000.
im trying to connect my local host client to deployed api, im getting an error which says "Error occurred while trying to proxy: localhost:3000/v1/auth/signin".
module.exports = (app) => { app.use( '/v1', createProxyMiddleware({ target: "https://aqueo.herokuapp.com/netlify/api/v1"}) ) }
But if i change the target from deployed address to local address its working fine. Not sure why deployed address is working.