Nodejs in Openshift MongoDB Error - node.js

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.

Related

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.

Error: getaddrinfo ENOTFOUND '0' when trying to start nuxt dev server

I wanted to start a nuxt dev server with this script in my package.json (my goal is to access the page from my mobile phone to test it):
"dev:host": "nuxt --hostname '0' --port 8000"
I basically copied the line from the nuxt docs (https://nuxtjs.org/docs/2.x/features/configuration#edit-host-and-port), but I get this error when executing the script:
FATAL getaddrinfo ENOTFOUND '0'
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26)
That's weird, because when I edit nuxt.config.js and add a server object with the same properties, it works (at least at my pc, i still can't access the page with my phone although its in the same network, but I guess that's a different problem). Has anyone stumbled across this dns.js error as well?
Replace '0' with 0.0.0.0 (no quotes). It works for me on Windows 11.
"dev:host": "nuxt --hostname 0.0.0.0 --port 80"
Not sure of the issue here since it's working totally fine on my side.
Maybe try with 0.0.0.0.
Also, what is your OS? It's maybe your #nuxt/cli version?
Here is my test repo: https://github.com/kissu/so-nuxt-vimeo
Maybe host one on github and share it to me, that way I may try and see if it's fine on my side or not (will help debugging if it's Nuxt or system related).

Deploy meteor app in Azure on Windows

Hello i am have meteor app and want deploy on Azure on Windows, i try it by Meteor Up but can't do it
***\project2>npm install -g mup
***\project2>mup init
Meteor Up: Production Quality Meteor Deployments
------------------------------------------------
Empty Project Initialized!
***\project2>mup setup
Meteor Up: Production Quality Meteor Deployments
------------------------------------------------
Started TaskList: Setup (linux) [23.101.74.119] - Installing Node.js events.js:85
throw er; // Unhandled 'error' event
^ Error: connect ETIMEDOUT
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
this error in Command Prompt of window from my local system
Looking at the error description it might be a connectivity issue. If you could share your mup.json file we might be able to spot the issue there.
Did you create an endpoint on TCP port 80? Check you nodeVersion setting so it corresponds to you Meteor app. The ROOT_URL should be in the format http://[myappname].cloudapp.net.
Using mup logs -n 50 you might detect some clues.

Unhandled rejection SequelizeConnectionError: connect ENOENT

I am stuck at a point. I am trying to start /connect using command "npm start" but unable to start npm on server.
I am getting this error:
Unhandled rejection SequelizeConnectionError: connect ENOENT
at Handshake._callback (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:63:20)
at Handshake.Sequence.end (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
at Protocol.handleNetworkError (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/mysql/lib/protocol/Protocol.js:358:14)
at Connection._handleNetworkError (/home/ec2-user/webapps/vactivity/node/vactivity/node_modules/mysql/lib/Connection.js:382:18)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
Apart from this my website work on nodejs & have nginx server configured on server.
Every thing started when I tried to set apache for adding a wordpress blog website. Since nginx already working on port 80. I was trying to set apache on another port so that everything work and ended up with above error. Now my website is not starting at all.
Edit:
My website is running using nodejs. I needed a wordpress blog website to run along and so i checked if there is a scope for apache on my server.
I found that apache along with nginx service was already running and mysql as well.
nginx is essential to run "adminer", a database management tool
Since nginx and apache was running on same ports, i tried to set apache on another port, other than default port.
After that I restarted apache, stopped mysql, stopped nginx and also stopped node
I used pkill node command for stopping node service.
Then restarted everything but got the above error.
I tried many things, and finally reset everything.
Ever since then I am stuck on this error.
Can anyone help?
I finally figured the problem and solved it.
Connect ENOENT means that system is unable to connect to mysql because its path is not correct.
As mentioned in an approved answer from Connect MySQL with Sequelize
Update your models/index.js file with the mentioned code.
To find you mysql socket path go to file here /etc/mysql/my.cnf ( this path may depend on your server). For my case it was /etc/my.cnf. Here you will find the socket path. Now paste this path to the code above and do npm start.
Problem is resolved. :)

Nodejs : Error get/response localhost

I'm running a Cakephp app with MAMP on localhost at port 80. I've also Node.js who listen/write on port 4000 with a js script from the Cake app (localhost/client).
When I call Node from js app, it works.
But, when I try to call a Cakephp page (localhost/saveData/123) from Node by http.get(); oder http.request for saving data in database, it crash.
events.js:71
throw arguments[1]; // Unhandled 'error' event
^ Error: connect ECONNREFUSED
at errnoException (net.js:770:11)
at Object.afterConnect [as oncomplete] (net.js:761:19)
Oder
problem with request: connect ECONNREFUSED
I've test width www.google.com, it works. It seems that's the problem is about "localhost".
Could someone help me? :)
EDIT : I've try with 127.0.0.1 too but it doesn't work (for MAMP and Node).
PS : sorry for my english, i'm french :)
Probably you have a local webserver running on port 80. Also programs like Skype can be connected to the port 80.
You can try close Skype and/or Webserver (XAMPP, WAMPP, usbwebserver, etc...).
Listing ports in Cmd.exe
$ netstat -a

Resources