StephenGrider / FullstackReactCode

Companion repo to https://www.udemy.com/node-with-react-fullstack-web-development
1.39k stars 1.17k forks source link

Getting a Proxy Error #24

Open wpk12345 opened 6 years ago

wpk12345 commented 6 years ago

Proxy error: Could not proxy request /api/current_user from localhost:3000 to http://localhost:5000/. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED). [1] [1] [HPM] Error occurred while trying to proxy request /api/current_user from localhost:3000 to http://localhost:5000/ (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

link to my github code: https://github.com/wpk12345/Emaily

wpk12345 commented 6 years ago

Yes but a month or so ago. I’ll have to look at the solution he sent and try to get back. Message him. He’s good about getting back.

Sent from my iPhone

On Jun 13, 2018, at 1:29 PM, Jarvis Potter notifications@github.com wrote:

I have the same Proxy error as well:

Proxy error: Could not proxy request /api/current_user from localhost:3000 to http://localhost:5000. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED). [1] [1] [HPM] Error occurred while trying to proxy request /api/current_user from localhost:3000 to http://localhost:5000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Did you fix the error?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jkp9qd commented 6 years ago

Ok, thank you.

Best,

Jarvis

On Wed, Jun 13, 2018 at 4:34 PM, William King notifications@github.com wrote:

Yes but a month or so ago. I’ll have to look at the solution he sent and try to get back. Message him. He’s good about getting back.

Sent from my iPhone

On Jun 13, 2018, at 1:29 PM, Jarvis Potter notifications@github.com wrote:

I have the same Proxy error as well:

Proxy error: Could not proxy request /api/current_user from localhost:3000 to http://localhost:5000. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED). [1] [1] [HPM] Error occurred while trying to proxy request /api/current_user from localhost:3000 to http://localhost:5000 (ECONNREFUSED) ( https://nodejs.org/api/errors.html#errors_common_system_errors)

Did you fix the error?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StephenGrider/FullstackReactCode/issues/24#issuecomment-397077137, or mute the thread https://github.com/notifications/unsubscribe-auth/AGfB7uBnHKXkPSrfLfPSChrMl8N5F1RUks5t8XdkgaJpZM4TsCmC .

jkp9qd commented 6 years ago

Hello Stephen,

Can you point me in the right direction to get fix this error?

Proxy error: Could not proxy request /api/current_user from localhost:3000 to http://localhost:5000.

[1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

[1]

[1] [HPM] Error occurred while trying to proxy request /api/current_user from localhost:3000 to http://localhost:5000 (ECONNREFUSED) ( https://nodejs.org/api/errors.html#errors_common_system_errors)

Best,

Jarvis

eponymz commented 6 years ago

If you run lsof -i :5000 then grab the id from the output then run kill then npm run dev you should be good.

jkp9qd commented 6 years ago

Ok,

-When I typed the command above there is no output for the id. How do I get the id for port 5000?

On Wed, Jun 13, 2018 at 5:45 PM, Ian Sabey notifications@github.com wrote:

If you run lsof -i :5000 then grab the id from the output then run kill then npm run dev you should be good.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StephenGrider/FullstackReactCode/issues/24#issuecomment-397097815, or mute the thread https://github.com/notifications/unsubscribe-auth/AGfB7gLJX_AlzyBP_dtLEZGxYVGMU4mhks5t8YfhgaJpZM4TsCmC .

eponymz commented 6 years ago

The command needs to be syntactically identical to what I put. <lsof -i :5000> make sure there is a space before typing the port.

On Wed, Jun 13, 2018, 11:22 PM Jarvis Potter notifications@github.com wrote:

Ok,

  • In the command I typed the following command - (Isof -i:5000)

-When I typed the command above there is no output for the id. How do I get the id for port 5000?

On Wed, Jun 13, 2018 at 5:45 PM, Ian Sabey notifications@github.com wrote:

If you run lsof -i :5000 then grab the id from the output then run kill then npm run dev you should be good.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/StephenGrider/FullstackReactCode/issues/24#issuecomment-397097815 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AGfB7gLJX_AlzyBP_dtLEZGxYVGMU4mhks5t8YfhgaJpZM4TsCmC

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StephenGrider/FullstackReactCode/issues/24#issuecomment-397174484, or mute the thread https://github.com/notifications/unsubscribe-auth/AZP62wjBiP-KKscpUavVRJdhhH-RqB-mks5t8fMcgaJpZM4TsCmC .

maevadevs commented 5 years ago

I get this error as well, sporadically... I think the following should fix this, @StephenGrider.

Fix

Force nodemon to ignore everything under client directory. client should be left for create-react-app alone to handle. So in package.json under server.

"server": "nodemon index.js --ignore './client/'",

explanation

I broke down the way to run the dev server (instead of using concurrently) and it seems the error is coming from the frontend. I get no error when saving a backend file, only from the client directory. Here is the error message in the frontend console:

Proxy error: Could not proxy request /api/current_user from localhost:3000 to http://localhost:5000.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

[HPM] Error occurred while trying to proxy request /api/current_user from localhost:3000 to http://localhost:5000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

An error message is also displayed in Chrome: Internal Server Error 500... After debugging the one in Chrome, it appears the error is coming from this.props.fetchUser() under componentDidMount of App.js

Only when saving a file in the client folder, both create-react-app's auto-reload and nodemon's auto-reload kick in. I believe this is creating a race-condition for the proxy at the frontend as both servers are temporarily down when restarting. If nodemon restart first then proxy works. If not, componentDidMount and fetchUser in App dispatch the action too earlier... Which is why sometimes it works, sometimes it crashes.

Johnny00520 commented 5 years ago

I have this issue when I try the bcrypt to hash the request password. So you think this is race-condition issue? If I don't use the hash function, I got 'Proxy error: Could not proxy request /api/signup from localhost:3000 to http://localhost:5005. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).'

I even try to ignore the /client in packet.json, but I still have the same error. What do you think?

reactnetau commented 5 years ago

Did anyone solve this?

LilaGuill commented 5 years ago

Hi I have the same issue rror occurred while trying to proxy request /search/AH from localhost:3000 to http://localhost:5000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

please help !

alireza1989 commented 5 years ago

I had the same issue. The problem is that you probably forgot to include dev.js in the config folder when you cloned the project. Since we did not want to include our Google client ID and secrets in the github repo we added that file to .gitignore.

I don't know why the error is not self explanatory but it will be solved once you add google creds (dev.js) files to the project.

Cheers

ghost commented 5 years ago

This error happens for many different reasons. All of the possible solutions here can potentially fix it up.

I had this same issue but for different reasons -- I had my ports switched on the backend and frontend code.

In my setup, the react app should run on port 3001. In the package.json, the proxy is set up to forward things to port 3000. Port 3000 is where the backend node app runs.

You can do export PORT=3001 when starting the react app and it cleared it up in my install.

I first noticed the issue because the login button wouldn't render. This happens because auth is set to null in my Header react component. auth is null because of the auth reducer returning null. The auth reducer returns null because state's default value is null. The default value stays as null because the action creator that produced FETCH_USER is hung on the axios call to /api/current_user. Axios gets hung because of the /api_current_user endpoint not existing on port 3000, which is where the port switch happens.

Samyaryal commented 5 years ago

What is the solution of this problem??

eponymz commented 5 years ago

@Samyaryal this the error is stating that the connection to Port 5000 was refused. So make sure you don't have anything running on it.

netEmmanuel commented 5 years ago

Did anyone get to resolve this issue?

brentEvans commented 5 years ago

None of the solutions posted here worked for me. Seems to be an identical error message:

[HPM] Error occurred while trying to proxy request /api/current_user from localhost:3000 to http://localhost:5000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Anyone figure this out?

onomemineadamu commented 5 years ago

Replace localhost to 127.0.0.1 in your package.json proxy

nelsonomuto commented 5 years ago

Using a parser like cookie parser or body parser can cause this issue

kawsher-hamid98 commented 4 years ago

"server": "nodemon server.js --ignore './client/'" try this..

reactnetau commented 4 years ago

"server": "nodemon server.js --ignore './client/'" try this..

THAT WORKED!

reactnetau commented 4 years ago

"server": "nodemon server.js --ignore './client/'" try this..

Worked for 5 minutes

khiltonsolidcad commented 4 years ago

I have been having the same problem and found this solution worked: https://github.com/saikat/react-apollo-starter-kit/issues/20#issuecomment-316651403

Vchau511 commented 4 years ago

Using a parser like cookie parser or body parser can cause this is

How can you remove body parser and cookie parser?

mythsand commented 4 years ago

It's all about the port issue, check it! Changing the listening port, or restarting the process may be solved.

mojtaba-7 commented 4 years ago

Hi my problem is the same, and after that: InternalOAuthError: Failed to fetch user profile at /home/mojtaba/Desktop/AdvancedNodeStarter/node_modules/passport-google-oauth20/lib/strategy.js:99:19 at passBackControl (/home/mojtaba/Desktop/AdvancedNodeStarter/node_modules/oauth/lib/oauth2.js:132:9) at IncomingMessage. (/home/mojtaba/Desktop/AdvancedNodeStarter/node_modules/oauth/lib/oauth2.js:157:7) at IncomingMessage.emit (events.js:327:22) at endReadableNT (_stream_readable.js:1221:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)

How to solve it?

ChristopherHButler commented 3 years ago

Hate to sound like a broken record but.... did anyone solve this one / find out WHY the error is occurring?

alisequeira commented 3 years ago

I think Stephen fix this error later on in the course. just keep watching the lectures.

nblake707 commented 3 years ago

I was having this issue bc I was in a different area but forgot to add the new ip address under network access in mongoDb cluster. The error went away afterwards.

Seelam-Ramesh-Reddy commented 3 years ago

Same Issue with Angular. Please help ASAP

[HPM] POST /api/sn/queryParams -> http:127.0.0.1:8081 [HPM] Error occurred while trying to proxy request /api/sn/queryParams from localhost:4200 to http:127.0.0.1:8081 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

MaltesBytes commented 3 years ago

👀. +1

ydrea commented 3 years ago

another one! See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

next-ruan-rita commented 3 years ago

Hi guys, I can using this method:

Replace localhost to 127.0.0.1 in your package.json proxy

mdarif commented 2 years ago

The issue is pretty much there in April 2022 as well.

davrope commented 2 years ago

In my case, this issue is related with something wrong in the backend server. I had a typo in a route (I typed a . instead of a ,). You can get a hint of what could go wrong if you read the error messages in the console and start debugging from there.

SanduDS commented 1 year ago

Hi guys, I can using this method:

Replace localhost to 127.0.0.1 in your package.json proxy

Be sure to restart deployment server