Using Google CloudSQL, getting "connect ECONNREFUSED 127.0.0.1:3306" - node.js

I'm trying my best to learn Google's Cloud Platform. They have a CloudSQL offering, which I'm learning via this NodeJS tutorial. Everything worked great until I deployed to their appspot server, at which point I got the following error:
connect ECONNREFUSED 127.0.0.1:3306
I've looked all through the NodeJS project and don't see anything in it or the Cloud Console that is referencing localhost or 127.0.0.1. Googling the error hasn't helped thus far. Any ideas?

I couldn't get this thing fixed when running on server but using this files I was able to read/write from local and production, now im using this connection strings in my own app
https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql
https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/cloudsql

I had a similar issue when deploying the nodejs sample app 2-structured-data
The reason why the error occurred is that the NODE_ENV environment variable was not passed to the config file that is used to check if node should use a socket for connecting to mysql
You can fix it by adding 'NODE_ENV' in the file config.js :
.env([
...
'NODE_ENV'])

Related

connection error while trying to connect mssql database to node js backend using knex

I recently cloned my existing node backend repo that worked properly about 3 months ago but now I can't connect my neither local nor remote MSSQL DB while I'm trying to call my endpoint in locally deployed backend below error occurred. I could use MSSM (Microsoft SQL SERVER MANAGEMENT) to connect to my DB using same credentials
These are the dependencies of my project
My Tedious connection config object
Environment variables (.env file)
I have tried upgrading my dependencies to latest, enabling TCP/IP of SQL server, also tried remote MSSQL server, tried to deploy and call the endpoint in different machine neither of them worked for me always the same error throw form backend.
Please refer to the Docker documentation, Declare default environment variables in file:
Each line represents a key-value pair. Values can optionally be quoted.
VAR=VAL -> VAL
VAR="VAL" -> VAL
VAR='VAL' -> VAL
You will notice that there are no comma , characters in the examples. Instead of your .env file containing the following:
DB_HOST="localhost",
DB_USER="admin",
DB_PASSWORD="Admin123",
It should contain the following instead (note: no commas):
DB_HOST="localhost"
DB_USER="admin"
DB_PASSWORD="Admin123"

"Resource temporarily unavailable" error trying to run nodejs app in AS/400

I need to connect a NodeJS to AS/400 server. In order to do that, I installed NodeJS in AS/400 with IBM documentation and tryed (succesfully) to send and receive data with Class iDataQueues (https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Toolkit%20for%20i%20APIs?section=Class%20iDataQueue) between AS/400 server and my develope computer. My next step was to run a program (Class iPgm) to received some data.
I'm running my test with
/path/to/ibm/node/installation/node /home/test/app.js"
and I'm getting a "node[537]: pthread_create: Resource temporarily unavailable" error, but I have no idea what is the problem:
Server has enough resources
There are not any node running in server
There are not any changes in server config between iDataQueue and iPgm tests
I have root privileges
I think my code is not the problem because I dont' even run it ¬¬'
This is caused by running node in QSH. By default QSH does not support running threads, so any attempt to create a thread will result in that "Resource temporarily unavailable" message. This can fixed by setting the environment variable QIBM_MULTI_THREADED=Y prior to running QSH, using QP2TERM, or using SSH.

I'm trying to deploy Node.js app to Google Cloud Platform but catching error with MongoDB

I've created a Node.js app and now I need to deploy it to Google Cloud Compute Engine. As it was shown in the guide I created new project in GSP, then I downloaded GSP SDK and created app.yaml with following code:
#[START app.yaml]
runtime: nodejs
env: flex
Then I ran gcloud app deploy and got following error:
name: 'MongoError',
message:
'failed to connect to server [localhost:27017] on first connect'
Error: KeystoneJS (seebelarus.by) failed to start - Check that you are running 'mongod' in a separate process.
So, what do I need to do, to fix this error?
That is saying it is trying to connect to Mongo locally. Was there a step in your tutorial perhaps for setting up a Mongo server?
My guess is that you need to create a Mongo server, and update the connection string to reference that one's location, as opposed to localhost.

Using mLab on Google App Engine through Wiki.js (Connection timeout)

I'm trying to set up a Node.js application using wiki.js: https://github.com/Requarks/wiki
I just started with Google App Engine and using their Cloud Shell. I installed Wiki.js using their bash command and ran a command that ran a server on port 3000 which I then used Google's shell to view.
It brings you to Wiki.js' configuration UI where you insert info including the mongodb connection string.
I have a DB in mlab set up with a user. I tested it locally to make sure I can connect, but when I try to do this process through the Google App Engine "Web Preview" they have on their command line, on the step where I am to add the mongodb connection string, it times out, giving the error:
Error: failed to connect to server [secret.mlab.com:secret] on first connect [MongoError: connection 8 to secret.mlab.com:secret timed out]
(i hid the actual address)
So i'm wondering if I'm missing something with this Google App Engine, since this connects successfully on my localhost

Check if site is alive through Heroku

I`ve build a simple project in nodejs to understand how things works. Everything looks fine on my local server, but when I push this to some cloud(Heroku) I get some strange errors.
The app baseline consist in checking if an address(hostname or ip) is "alive", so I've decided to try some of ping packages on npm(ping and ping-lite). Both of them works properly on my localserver, but when pushed to heroku i got this:
/app/node_modules/ping-lite/ping-lite.js:39
throw new Error('Could not detect '+this._bin+' on your system');
I do not understand a lot of network/tcp-ip stuff, but both of this packages are wrappers for "sys ping" does this mean that I can't use these because heroku does not allow performing a sys ping?
If that is true what I could do to check if an address is alive?
Note: I`m currently doing a http get request to check this, but this do not work with address like (8.8.8.8, dns or public dns) .

Resources