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 occured while trying to proxy to: localhost:3000/hello #19

Closed
cezarneaga opened this issue Jan 8, 2019 · 27 comments
Closed

Error occured while trying to proxy to: localhost:3000/hello #19

cezarneaga opened this issue Jan 8, 2019 · 27 comments

Comments

@cezarneaga
Copy link

cezarneaga commented Jan 8, 2019

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

@swyxio
Copy link
Contributor

swyxio commented Jan 9, 2019

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?

@cezarneaga
Copy link
Author

am using nvm. have some other versions of node. but nothing else out of the ordinary

@swyxio
Copy link
Contributor

swyxio commented Jan 10, 2019

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

@swyxio
Copy link
Contributor

swyxio commented Jan 10, 2019

https://www.youtube.com/watch?v=3ldSM98nCHI

@ghost

This comment has been minimized.

@swyxio

This comment has been minimized.

@cezarneaga
Copy link
Author

I followed the video too, and i get the same error :(

Also on lts:carbon

This is so weird.

@swyxio
Copy link
Contributor

swyxio commented Jan 11, 2019

this is gonna sound really stupid but have you tried restarting your computer

@cezarneaga
Copy link
Author

cezarneaga commented Jan 14, 2019 via email

@swyxio
Copy link
Contributor

swyxio commented Jan 14, 2019

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.

@swyxio swyxio closed this as completed Jan 14, 2019
@cezarneaga
Copy link
Author

i know. clicking on the button returns the 504
not accessing the /hello page

@swyxio
Copy link
Contributor

swyxio commented Jan 14, 2019

happy to reopen the issue if you wanna share a repro, i have no idea how else to help you.

@grgcnnr
Copy link

grgcnnr commented Apr 1, 2019

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.

@She-Codes
Copy link

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.jsonfile did. My React app is running on http://localhost:3000/ and my Netlify functions running on http://localhost:8888/.

@swyxio
Copy link
Contributor

swyxio commented Aug 30, 2019

at this point i really recommend using netlify dev so you dont have to configure all this gunk :)

@She-Codes
Copy link

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.

@mordechaim
Copy link

Happened to me when I forgot to put http:// but instead just typed localhost:9000

@vashisth00
Copy link

Error occurred while trying to proxy request /api/video/thumbnail from localhost:3000 to http://localhost:5001/

Sucks

@KostisPoly
Copy link

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.

@RichardTMiles
Copy link

RichardTMiles commented Nov 10, 2021

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.

@erfanSW
Copy link

erfanSW commented Jan 26, 2022

I face this issue when I'm trying to proxy request from localhost:XXXX to localhost:YYYY

@RichardTMiles
Copy link

RichardTMiles commented Jun 4, 2022

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.

  1. My etc hosts file contain multiple domains pointed for

Screen Shot 2022-06-04 at 2 05 09 PM

  1. When the 504 - starts

Screen Shot 2022-06-04 at 2 09 26 PM

  1. I can use another domain in the list in the /etc/hosts file and the request will successfully be made to APACH!!!!

  2. 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

Screen Shot 2022-06-04 at 2 03 36 PM

// happy hacking

@RichardTMiles
Copy link

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.

Screen Shot 2022-06-26 at 12 41 38 PM

@RichardTMiles
Copy link

@RichardTMiles
Copy link

copied from here..

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. :)

@aceamarco
Copy link

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.

@shetty-nithin
Copy link

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.

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

No branches or pull requests