Why do I get ECONNREFUSED proxy error with nodejs & react? - javascript

I'm using react to build a web application with an API. The API is on localhost:3000 and the react app on localhost:5000.
Sometimes when the server reloads I get this error message in the terminal:
[1] Compiling...
[0] [nodemon] starting `node server.js`
[1] Compiled successfully!
[1] Proxy error: Could not proxy request /api/auth from localhost:5000 to http://localhost:3000/.
[1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
It seems like the app works fine with it, it does say it compiles successfully and it's working just fine with the database. I thought maybe the problem was that is was contacting localhost:5000 instead of http://localhost:5000/, but I don't know how to change that.
What is that error and why am I getting it?

Related

Why does my localhost:3000 not work (error 500)

I am trying to follow a tutorial but i run into problems before i even have written a line of code. only terminal commands as seen below:
*PS C:\Users\ruben\OneDrive\Bureaublad\dapp> cd .\client\
PS C:\Users\ruben\OneDrive\Bureaublad\dapp\client> npm init vite#latest
√ Project name: ... ./
√ Select a framework: » react
√ Select a variant: » react
Scaffolding project in C:\Users\ruben\OneDrive\Bureaublad\dapp\client\...
Done. Now run:
npm install
npm run dev
PS C:\Users\ruben\OneDrive\Bureaublad\dapp\client> npm install
added 76 packages, and audited 77 packages in 6s
7 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
PS C:\Users\ruben\OneDrive\Bureaublad\dapp\client> npm run dev
> dapp1#0.0.0 dev
> vite
Pre-bundling dependencies:
react
react-dom
react/jsx-dev-runtime
(this will be run only when your dependencies or config have changed)
vite v2.7.10 dev server running at:
> Local: http://localhost:3000/
> Network: use `--host` to expose
ready in 467ms.*
When i go to the localhost i get presented a blank page (in the tutorial it shows a visual and some text.
When i inspect the page i get presented by there errors:
:3000/:1
GET http://localhost:3000/ 500 (Internal Server Error)
localhost/:1
GET http://localhost:3000/_next/static/chunks/fallback/webpack.js?ts=1641050312655
net::ERR_ABORTED 500 (Internal Server Error)
localhost/:1
GET http://localhost:3000/_next/static/chunks/fallback/main.js?ts=1641050312655
net::ERR_ABORTED 500 (Internal Server Error)
localhost/:1
GET http://localhost:3000/_next/static/chunks/fallback/react-refresh.js?
ts=1641050312655 net::ERR_ABORTED 500 (Internal Server Error)
localhost/:1
GET http://localhost:3000/_next/static/chunks/fallback/pages/_app.js?
ts=1641050312655 net::ERR_ABORTED 500 (Internal Server Error)
localhost/:1
GET http://localhost:3000/_next/static/chunks/fallback/pages/_error.js?
ts=1641050312655 net::ERR_ABORTED 500 (Internal Server Error)
Aswel as this issue:
A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.
To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.
Note that for performance reasons, only the first access to one of the properties is shown.
1 source
bubble_compiled.js:1
This could be a permission issue. You are working inside OneDrive folder. So there is a probability that OneDrive is constantly watching every change inside the inner folders and blocking access for other applications. Try starting your project anew in another folder. Preferably in 'C:\Users\ruben\Desktop'.
Make sure that you are using at least npm v6 i just tried this on node v17 and it is working fine on npm v7.
The docs that i followed is here

ExpressJS webseite works local but returns 403 Forbidden online

I'm trying to get this example ExpressJS app running on my server.
Offline (on localhost) it is working correctly after running npm start.
I uploaded all files, installed everything through npm install, started the nodemon through SSH npm startand got the App Running response.
If I try now to open the URL of the website it returns 403 Forbidden.
What do I need to change to make it work?
(It's my first time working with ExpressJS - maybe it's just a noob issue. Could this be a HOST or PORT issue?)

Undefined error in build version with electron

I have an electron app, the app is working when I am running:
npm run electron-dev
I am creating a build folder using react-scripts:
yarn react-scripts build
Than I am trying to build it using electron builder with the command:
yarn electron-builder -c.extraMetadata.main=build/electron.js
This is working well and I am getting a dist and a build folders with the compiled app and a build.
But when I am clicking the app I am getting:
A JavaScript error occurred in the main process
Uncaught Exception:
undefined: undefined
Compilation success messages
When running the app via electron-dev (on the build folder or on the public folder) I am getting no errors, but I am getting 3 warning messages, 2 from firebase - "When deploying Firebase apps to production, it is advisable to only import the individual SDK components you intend to use.", "Warning: This is a browser-targeted Firebase bundle but it appears it is being run in a Node environment." and 1 about security "Electron Security Warning (Insecure Content-Security-Policy) This renderer process has either no Content Security Policy set or a policy with "unsafe-eval" enabled.".
TD;DR: How can I understand where the error is coming from and why, if the error shows only undefined: undefined?
Maybe through try and catch but than how can I display it on the error I am getting?
I'm working on Mac OSX (But it does not looks like this is the problem), I am using opencv4nodejs which takes a long time to compile, also I am using some json files to store app data using electron-json-storage.

Meteor: Error: ENOTEMPTY: directory not empty when deploying to Modulus

I'm deploying a Meteor app to Modulus.io. I had no problems at all deploying it with modulus deploy in the last couple of days but after a couple of changes to my app I now get the following error:
Error: ENOTEMPTY: directory not empty
It happens at a very late stage of their script, here's the full log from the terminal:
deploy -> v0.10.36
Uploading completed build.
Provisioning and deploying bundle to servos...
fs.js:807
return binding.rmdir(pathModule._makeLong(path));
^
Error: ENOTEMPTY: directory not empty, rmdir '/Users/andreaswest/Documents/workspace/test2/.demeteorized'
at Error (native)
at Object.fs.rmdirSync (fs.js:807:18)
at Object.removeSync (/usr/local/lib/node_modules/modulus/node_modules/fs-tools/lib/fs-tools.js:420:8)
at /usr/local/lib/node_modules/modulus/lib/controllers/project.js:279:21
at /usr/local/lib/node_modules/modulus/lib/controllers/project.js:383:19
at /usr/local/lib/node_modules/modulus/lib/controllers/project.js:354:9
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/modulus/lib/librarian/http.js:134:9)
at emitNone (events.js:73:20)
at IncomingMessage.emit (events.js:167:7)
at endReadableNT (_stream_readable.js:906:12)
Can anyone help?
This is the answer I got from David Berger from Modulus support:
Hey Andreas,
Sometimes this will happen and the deploy will have been successful, but the CLI failed to do a little cleanup afterwards. If your deploy is not working from the CLI, we recommend trying to deploy from the web dashboard: https://my.modulus.io/project/57316
If you deploy from the web dashboard, create a zip of your project files, and then upload it via the ‘deploy files’ upload in the upper right hand corner of the dashboard.

Unable to deploy Node app to Openshift

I'm trying to deploy a simple ExpressJS app I have to Openshift using the command line tools. I've provided a debug trace below:
>npm info ok
Preparing build for deployment
Deployment id is 5e2abc99
Activating deployment
HAProxy already running
HAProxy instance is started
Starting NodeJS cartridge
Sat Aug 15 2015 15:17:47 GMT-0400 (EDT): Starting application 'xxxxx' ...
Waiting for application port (8080) become available ...
Application 'xxxxx' failed to start (port 8080 not available)
and
Git Post-Receive Result: failure
Activation status: failure
Activation failed for the following gears:
55cf8fc589f5cf9dbf00023c (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/55cf8fc589f5cf9dbf00023c/nodejs
#<IO:0x00000001ec7290>
#<IO:0x00000001ec7218>
>)
Deployment completed with status: failure
postreceive failed
However my app is listening on port 8080:
app.listen(process.env.OPENSHIFT_NODEJS_PORT || 8080);
Can anyone help?
Deploying an empty application doesn't seem to throw any errors.
Have you checked the log on the server? I was encountering a similar issue and it was because I had syntax errors in my script. If you SSH into your application and
tail app-root/logs/nodejs.log
you can see the console output for the app. Use -n [# of lines] to view more of the log if 10 isn't enough or use less and press shift + g to view the document starting at the bottom if you want to scroll up and down through it all.
Try to login via ssh to your openshift node. I use the rhc tool. Run your code and you will see where the problem is.

Categories