FullstackReactCode icon indicating copy to clipboard operation
FullstackReactCode copied to clipboard

Getting a Proxy Error

Open wpk12345 opened this issue 7 years ago • 36 comments

wpk12345 avatar Apr 30 '18 01:04 wpk12345

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 avatar Apr 30 '18 01:04 wpk12345

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 [email protected] 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.

wpk12345 avatar Jun 13 '18 20:06 wpk12345

Ok, thank you.

Best,

Jarvis

On Wed, Jun 13, 2018 at 4:34 PM, William King [email protected] 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 [email protected] 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 avatar Jun 13 '18 20:06 jkp9qd

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

jkp9qd avatar Jun 13 '18 21:06 jkp9qd

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

eponymz avatar Jun 13 '18 21:06 eponymz

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 [email protected] 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 .

jkp9qd avatar Jun 14 '18 05:06 jkp9qd

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 [email protected] 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 [email protected] 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 .

eponymz avatar Jun 14 '18 05:06 eponymz

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.

maevadevs avatar Sep 21 '18 22:09 maevadevs

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?

Johnny00520 avatar Oct 07 '18 04:10 Johnny00520

Did anyone solve this?

reactnetau avatar Dec 25 '18 07:12 reactnetau

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 !

LilaGuill avatar Jan 27 '19 13:01 LilaGuill

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

alireza1989 avatar Feb 11 '19 20:02 alireza1989

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.

ghost avatar Mar 30 '19 21:03 ghost

What is the solution of this problem??

Samyaryal avatar Jun 11 '19 18:06 Samyaryal

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

eponymz avatar Jun 11 '19 19:06 eponymz

Did anyone get to resolve this issue?

netEmmanuel avatar Jun 17 '19 11:06 netEmmanuel

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?

brentEvans avatar Jun 22 '19 01:06 brentEvans

Replace localhost to 127.0.0.1 in your package.json proxy

onomemineadamu avatar Jun 27 '19 12:06 onomemineadamu

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

nelsonomuto avatar Jul 27 '19 05:07 nelsonomuto

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

kawsher-hamid98 avatar Nov 01 '19 06:11 kawsher-hamid98

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

THAT WORKED!

reactnetau avatar Nov 15 '19 02:11 reactnetau

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

Worked for 5 minutes

reactnetau avatar Nov 15 '19 03:11 reactnetau

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

khiltonsolidcad avatar Dec 17 '19 19:12 khiltonsolidcad

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

How can you remove body parser and cookie parser?

Vchau511 avatar Apr 29 '20 23:04 Vchau511

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

mythsand avatar Jun 18 '20 02:06 mythsand

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?

mojtaba-7 avatar Jul 04 '20 19:07 mojtaba-7

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

ChristopherHButler avatar Nov 10 '20 22:11 ChristopherHButler

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

alisequeira avatar Nov 17 '20 21:11 alisequeira

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.

nblake707 avatar Apr 22 '21 00:04 nblake707

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)

Seelam-Ramesh-Reddy avatar May 28 '21 18:05 Seelam-Ramesh-Reddy