Error: connect ECONNREFUSED when making https request on same server running nginx - node.js

Since a recent Plesk update on my server I been having issues with my nodejs apps making requests to api urls hosted on the same server and a bit lost as to whats causing it as they use to run fine. The api domain in question is still serving the site using apache but when my nodejs app makes a request to the site using https I get the error
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
however loading the same url in my browser loads fine.

Related

Node.js HTTP requests: "EAI_AGAIN" DNS errors on Raspberry Pi

I have a node.js server that fetches data from several APIs.
Most of them are constantly giving this same error over time when fetching an http request with axios:
errno: -3001,
code: 'EAI_AGAIN',
syscall: 'getaddrinfo'
This is only happening on my Raspberry Pi. If I run this server on say my PC this error doesn't occur.
I'm guessing this is a DNS timeout? Why does this happen only on my raspberry pi? (it's connected to the same network as my PC).
Do I need to extend the timeout (and if so, how?) or is there a linux command I need to issue or a node package I need to install?
This is happening quite frequently.

connect EtimedOut <proxy server>:port nodejs using axios

I am facing an issue, where I am trying to call our own application web apis hosted on azure from nodeJS using axios and getting below error:
Error: connect ETIMEDOUT :443

PostgreSQL node server connecting to local pg rather than cloud (digitalocean)

Hi I am trying to connect to Postgres on digital ocean with a node basic server, but every time I hit a api end point like localhost:3001 etc instead of trying to connect to the pg on DO I get connected or try to connect to pg locally.
The credentials and config params all point to the digital ocean pg so I am not sure why is it trying to connect to the local pg on my Mac. I have a M1 Mac.
Another question is do I need pg locally installed to connect to DO pg? I removed the pg locally uninstalling everything and tried to connect to DO pg but it won't work, I get an error:
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}
The reason I am asking is that I have almost exact logic on a electron node app, with the same configs and params pointing to DO pg and I can connect and fetch data etc it works either with local pg installed or with pg uninstalled locally so I am really confused.
On the node server I am using node pg npm package, which works fine on my electron app without the need of a local pg installed.
Please let me know.
So the problem was the .env vars not being mounted properly on the data.js configuration, meaning they were not defined and so node pg would automatically try to connect to local pg.
After inserting dotenv package on the data.js it works.

Node js Axios Get Error: getaddrinfo ENOTFOUND

I have a code to connect to a server to get an image. It is working fine on the local host, but when I host my web app to azure and try to call the same server, I get this Error: getaddrinfo ENOTFOUND error. If I change the host name in the url to ip address, I am getting a certificate error. Any inputs would be of great help

Nodejs in Openshift MongoDB Error

This could probably be very stupid and naive question, but I have tried all my ways to find the solution, but I'm unable to solve. Hope anyone can solve my problem. Thanks in advance.
Recently, I deployed my nodejs application in Open Shift using Mongolab driver for the MongoDB. When I run the application using 'rhc app start -a nodejs', it gives me an ECONNREFUSED error in mongooose.
Error: connect ECONNREFUSED
at errnoException (net.js:905:11)
at Object.afterConnect [as oncomplete] (net.js:896:19)
But, when I SSH into the server, go to $OPENSHIFT_REPO_DIR directory and use npm start, the app works very fine.
I connect to the mongodb by defining the URI as shown
mongoose.connect(process.env.MONGOLAB_URI || 'mongodb://localhost/<dbname>');
I defined the MONGOLAB_URI as an environmental variable in the server.
There would probably be something that I'm missing. But, please bare with this naive.

Resources