unable to login after deploying Jhipster (webflux) to Heroku - jhipster

after deploying a jhipster fresh created app to Heroku the app is successfully deployed however I'm not able to sign in getting the following error
io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: localhost/127.0.0.1:3306 Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused app[web.1]: at io.netty.channel.unix.Errors.throwConnectException(Errors.java:124) app[web.1]: at io.netty.channel.unix.Socket.finishConnect(Socket.java:243) app[web.1]:at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:672) app[web.1]: at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:649) app[web.1]: atio.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:529) app[web.1]: at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:465) app[web.1]: at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) app[web.1]: at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app[web.1]: at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app[web.1]: at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) app[web.1]: at java.base/java.lang.Thread.run(Thread.java:834)
what I tried
changed src/main/resources/config/application-heroku.yml spring:datasource to use the output from heroku config DATABASE_URL

Related

Deploy Node JS app onto AWS EC2 with CodeDeploy

I'm trying to deploy a very basic Node JS application onto an AWS EC2 instance with CodeDeploy. I'm running into an issue where the deployment fails because the Node JS app is already running on the port the application is running on. I'm not sure entirely how to approach this situation. The app is designed to run on port 3000. Below is the error message I get from the script that CodeDeploy is executing. I tried going into the instance and terminate the process that is running on port 3000, but it seems after terminating the process the application spins right back up. Please let me know if anything is needed to be helpful. Any advice would be appreciated.
Error
[stderr]+ return 1
[stderr]+ '[' -n 'Now using node v16.15.0 (npm v8.5.5)' ']'
[stderr]+ '[' 0 -ne 1 ']'
[stderr]+ nvm_echo 'Now using node v16.15.0 (npm v8.5.5)'
[stderr]+ command printf '%s\n' 'Now using node v16.15.0 (npm v8.5.5)'
[stdout]Now using node v16.15.0 (npm v8.5.5)
[stderr]+ EXIT_CODE=0
[stderr]+ set -e
[stderr]+ return 0
[stderr]+ npm ci
[stdout]
[stdout]added 183 packages, and audited 184 packages in 1s
[stdout]
[stdout]16 packages are looking for funding
[stdout] run `npm fund` for details
[stdout]
[stdout]1 critical severity vulnerability
[stdout]
[stdout]To address all issues (including breaking changes), run:
[stdout] npm audit fix --force
[stdout]
[stdout]Run `npm audit` for details.
[stderr]+ npm start
[stdout]
[stdout]> web#0.0.1 start
[stdout]> node server.js
[stdout]
[stderr]node:events:505
[stderr] throw er; // Unhandled 'error' event
[stderr] ^
[stderr]
[stderr]Error: listen EADDRINUSE: address already in use :::3000
[stderr] at Server.setupListenHandle [as _listen2] (node:net:1372:16)
[stderr] at listenInCluster (node:net:1420:12)
[stderr] at Server.listen (node:net:1508:7)
[stderr] at Object.<anonymous> (/home/ec2-user/Web/server.js:47:8)
[stderr] at Module._compile (node:internal/modules/cjs/loader:1105:14)
[stderr] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
[stderr] at Module.load (node:internal/modules/cjs/loader:981:32)
[stderr] at Function.Module._load (node:internal/modules/cjs/loader:822:12)
[stderr] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
[stderr] at node:internal/main/run_main_module:17:47
[stderr]Emitted 'error' event on Server instance at:
[stderr] at emitErrorNT (node:net:1399:8)
[stderr] at processTicksAndRejections (node:internal/process/task_queues:83:21) {
[stderr] code: 'EADDRINUSE',
[stderr] errno: -98,
[stderr] syscall: 'listen',
[stderr] address: '::',
[stderr] port: 3000
[stderr]}
you can change port number in your project or you can kill 3000 port at EC2 instance :).

Can I run nodejs child-process (command line) in heroku?

I have created an app.js file that tries to run node span child-process. With that child process I tried to run mongodump (mongodb utility to create backups). In my local computer that codes works but in my node server in heroku the code fails and throws an error like:
2021-08-20T01:17:29.655225+00:00 app[web.1]: node:events:371
2021-08-20T01:17:29.655250+00:00 app[web.1]: throw er; // Unhandled 'error' event
2021-08-20T01:17:29.655250+00:00 app[web.1]: ^
2021-08-20T01:17:29.655250+00:00 app[web.1]:
2021-08-20T01:17:29.655251+00:00 app[web.1]: Error: spawn mongodump ENOENT
2021-08-20T01:17:29.655251+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
2021-08-20T01:17:29.655252+00:00 app[web.1]: at onErrorNT (node:internal/child_process:480:16)
2021-08-20T01:17:29.655252+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:83:21)
2021-08-20T01:17:29.655252+00:00 app[web.1]: Emitted 'error' event on ChildProcess instance at:
2021-08-20T01:17:29.655253+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
2021-08-20T01:17:29.655253+00:00 app[web.1]: at onErrorNT (node:internal/child_process:480:16)
2021-08-20T01:17:29.655253+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2021-08-20T01:17:29.655253+00:00 app[web.1]: errno: -2,
2021-08-20T01:17:29.655254+00:00 app[web.1]: code: 'ENOENT',
2021-08-20T01:17:29.655254+00:00 app[web.1]: syscall: 'spawn mongodump',
2021-08-20T01:17:29.655254+00:00 app[web.1]: path: 'mongodump',
2021-08-20T01:17:29.655255+00:00 app[web.1]: spawnargs: [
2021-08-20T01:17:29.655255+00:00 app[web.1]: '--gzip',
2021-08-20T01:17:29.655255+00:00 app[web.1]: '--uri',
2021-08-20T01:17:29.655255+00:00 app[web.1]: 'my_mongo_atlas_uri,
2021-08-20T01:17:29.655255+00:00 app[web.1]: '--forceTableScan'
2021-08-20T01:17:29.655256+00:00 app[web.1]: ]
2021-08-20T01:17:29.655256+00:00 app[web.1]: }
2021-08-20T01:17:29.732198+00:00 heroku[web.1]: Process exited with status 1
Can anyone suggest what am i missing?
So, i have figured this out by myself.
Heroku doesn't understand mongodump or mongorestore or any other mongodb utilities command by itself. You have to add mongodb utilities build-packs to you app/server. You can add them by:
heroku buildpacks:add https://github.com/uhray/heroku-buildpack-mongo.git
heroku buildpacks:add heroku/nodejs
After adding this, redeploy you server. Now it can support mongo utilities commands.
Reference taken from: heroku buildpacks:add https://github.com/uhray/heroku-buildpack-mongo.git

KeystoneJS V4 app that used to work when deploying to Heroku is now stopped working - MongoDB Atlas

A KeystoneJS V4 app which was running & working perfectly connected to MongoDB Atlas few months ago was deleted by Heroku due to some stack change. Now I'm trying to deploy the same app with correct configurations but there's a deployment error. Here's the error I'm getting:
2021-06-23T17:14:40.418968+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-23T17:14:43.000000+00:00 app[api]: Build succeeded
2021-06-23T17:14:46.464645+00:00 heroku[web.1]: Starting process with command `node keystone.js`
2021-06-23T17:14:49.588440+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2021-06-23T17:14:49.588949+00:00 app[web.1]: designed for a production environment, as it will leak
2021-06-23T17:14:49.588950+00:00 app[web.1]: memory, and will not scale past a single process.
2021-06-23T17:14:49.711527+00:00 app[web.1]: ------------------------------------------------
2021-06-23T17:14:49.711682+00:00 app[web.1]: Mongoose connection "error" event fired with:
2021-06-23T17:14:49.712891+00:00 app[web.1]: Error [MongoError]: failed to connect to server [cluster-1z703hln.tt6wq.mongodb.net:27017] on first connect
2021-06-23T17:14:49.712894+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:326:35)
2021-06-23T17:14:49.712894+00:00 app[web.1]: at Pool.emit (events.js:314:20)
2021-06-23T17:14:49.712894+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:272:12)
2021-06-23T17:14:49.712895+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2021-06-23T17:14:49.712895+00:00 app[web.1]: at Connection.emit (events.js:314:20)
2021-06-23T17:14:49.712896+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:175:49)
2021-06-23T17:14:49.712896+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2021-06-23T17:14:49.712897+00:00 app[web.1]: at Socket.emit (events.js:314:20)
2021-06-23T17:14:49.712897+00:00 app[web.1]: at emitErrorNT (internal/streams/destroy.js:92:8)
2021-06-23T17:14:49.712897+00:00 app[web.1]: at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
2021-06-23T17:14:49.712899+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21)
2021-06-23T17:14:49.713715+00:00 app[web.1]: Error: KeystoneJS (My-App) failed to start - Check that you are running `mongod` in a separate process.
2021-06-23T17:14:49.713716+00:00 app[web.1]: at NativeConnection.<anonymous> (/app/node_modules/keystone/lib/core/openDatabaseConnection.js:59:10)
2021-06-23T17:14:49.713716+00:00 app[web.1]: at NativeConnection.emit (events.js:314:20)
2021-06-23T17:14:49.713717+00:00 app[web.1]: at Immediate.<anonymous> (/app/node_modules/mongoose/lib/connection.js:296:19)
2021-06-23T17:14:49.713717+00:00 app[web.1]: at processImmediate (internal/timers.js:461:21)
2021-06-23T17:14:49.801512+00:00 heroku[web.1]: Process exited with status 1
2021-06-23T17:14:49.940361+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-23T17:14:49.950336+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-23T17:14:57.803099+00:00 heroku[web.1]: Starting process with command `node keystone.js`
2021-06-23T17:15:02.052669+00:00 heroku[web.1]: Process exited with status 1
2021-06-23T17:15:02.247835+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-23T17:15:01.788675+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2021-06-23T17:15:01.788702+00:00 app[web.1]: designed for a production environment, as it will leak
2021-06-23T17:15:01.788703+00:00 app[web.1]: memory, and will not scale past a single process.
2021-06-23T17:15:01.971420+00:00 app[web.1]: ------------------------------------------------
2021-06-23T17:15:01.971542+00:00 app[web.1]: Mongoose connection "error" event fired with:
2021-06-23T17:15:01.975012+00:00 app[web.1]: Error [MongoError]: failed to connect to server [cluster-1z703hln.tt6wq.mongodb.net:27017] on first connect
2021-06-23T17:15:01.975013+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:326:35)
2021-06-23T17:15:01.975014+00:00 app[web.1]: at Pool.emit (events.js:314:20)
2021-06-23T17:15:01.975014+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:272:12)
2021-06-23T17:15:01.975014+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2021-06-23T17:15:01.975015+00:00 app[web.1]: at Connection.emit (events.js:314:20)
2021-06-23T17:15:01.975015+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:175:49)
2021-06-23T17:15:01.975016+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2021-06-23T17:15:01.975016+00:00 app[web.1]: at Socket.emit (events.js:314:20)
2021-06-23T17:15:01.975016+00:00 app[web.1]: at emitErrorNT (internal/streams/destroy.js:92:8)
2021-06-23T17:15:01.975017+00:00 app[web.1]: at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
2021-06-23T17:15:01.975017+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21)
2021-06-23T17:15:01.975867+00:00 app[web.1]: Error: KeystoneJS (My-APP) failed to start - Check that you are running `mongod` in a separate process.
2021-06-23T17:15:01.975868+00:00 app[web.1]: at NativeConnection.<anonymous> (/app/node_modules/keystone/lib/core/openDatabaseConnection.js:59:10)
2021-06-23T17:15:01.975868+00:00 app[web.1]: at NativeConnection.emit (events.js:314:20)
2021-06-23T17:15:01.975868+00:00 app[web.1]: at Immediate.<anonymous> (/app/node_modules/mongoose/lib/connection.js:296:19)
2021-06-23T17:15:01.975869+00:00 app[web.1]: at processImmediate (internal/timers.js:461:21)
Can someone help me with this please. Not sure why I'm getting this error. I have the correct MONGODB_URI (which works fine on another app).
That error (failed to connect to server) is coming straight from Mongoose so it's a problem with the DB connection. The cause is probably either...
Networking
Atlas blocks all traffic by default; for Heroku deploys you need to open it up by configuring the access list. In this case it should contain something like 0.0.0.0/32 to allow all IPs. (I know you said the DB is accessible from another app but still worth checking.)
Auth
Does the URI contain the username password? It should be in the form...
mongodb+srv://<username>:<password>#cluster-1z703hln.tt6wq.mongodb.net/my-app?retryWrites=true&w=majority
.. or similar, not the shorter form that Atlas suggests for the CLI, eg.
mongodb+srv://cluster-1z703hln.tt6wq.mongodb.net/my-app
What happens when you attempt to connect from mongo client on your dev machine? It may give a more helpful error message.

Mongoose is not connecting to mongodb-atlas

The code runs without error when the server is local, but when i try to connect to mongodb-atlas it shows an error.
//mongoose.connect("mongodb+srv://namdi:#yelpcamp-wd2aa.mongodb.net/test?retryWrites=true&w=majority", { useNewUrlParser: true });
2019-06-20T10:55:44.983125+00:00 heroku[web.1]: Starting process with command npm start
2019-06-20T10:55:47.498330+00:00 app[web.1]:
2019-06-20T10:55:47.498348+00:00 app[web.1]: > v1#1.0.0 start /app
2019-06-20T10:55:47.498350+00:00 app[web.1]: > node app.js
2019-06-20T10:55:47.498352+00:00 app[web.1]:
2019-06-20T10:55:48.078344+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2019-06-20T10:55:48.078381+00:00 app[web.1]: designed for a production environment, as it will leak
2019-06-20T10:55:48.078384+00:00 app[web.1]: memory, and will not scale past a single process.
2019-06-20T10:55:48.090007+00:00 app[web.1]: YelpCamp don start
2019-06-20T10:55:48.219655+00:00 app[web.1]: (node:23)
UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [yelpcamp-shard-00-00-wd2aa.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to yelpcamp-shard-00-00-wd2aa.mongodb.net:27017 closed]

Yeoman grunt could not connect to MongoDB

I have been trying to run a Yeoman generated app, but every single time I run the command grunt, I run into the same error:
PS C:\Users\Aiden\yo\mean> grunt
Loading "grunt-karma.js" tasks...ERROR
>> TypeError: Cannot read property 'prototype' of undefined
>> Local Npm module "grunt-node-inspector" not found. Is it installed?
Running "env:dev" (env) task
Running "sass:dist" (sass) task
Warning:
You need to have Ruby and Sass installed and in your PATH for this task to
work.
More info: https://github.com/gruntjs/grunt-contrib-sass
Used --force, continuing.
Running "less:dist" (less) task
Running "jshint:all" (jshint) task
>> 87 files lint free.
Running "csslint:all" (csslint) task
>> 2 files lint free.
Running "mkdir:upload" task
Running "copy:localConfig" (copy) task
Running "concurrent:default" (concurrent) task
Loading "grunt-karma.js" tasks...ERROR
>> TypeError: Cannot read property 'prototype' of undefined
Loading "grunt-karma.js" tasks...ERROR
>> TypeError: Cannot read property 'prototype' of undefined
>> Local Npm module "grunt-node-inspector" not found. Is it installed?
>> Local Npm module "grunt-node-inspector" not found. Is it installed?
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: server.js config/**/*.js modules/*/server/**/*.js
[nodemon] starting `node --debug server.js`
(node:8744) DeprecationWarning: node --debug is deprecated. Please use node --inspect instead.
Debugger listening on 127.0.0.1:5858
Could not connect to MongoDB!
{ MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (C:\Users\Aiden\yo\mean\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\server.js:328:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:191:7)
at Connection.<anonymous>
(C:\Users\Aiden\yo\mean\node_modules\mongoose\node_modules\mongodb-
core\lib\connection\pool.js:274:1
2)
at Object.onceWrapper (events.js:293:19)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:194:7)
at Socket.<anonymous>
(C:\Users\Aiden\yo\mean\node_modules\mongoose\node_modules\mongodb-
core\lib\connection\connection.js:177
:49)
at Object.onceWrapper (events.js:293:19)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at emitErrorNT (net.js:1279:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'MongoError',
message: 'failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]' }
C:\Program Files\nodejs\node.exe: src\debug-agent.cc:147: Assertion `(err) == (0)' failed.
[nodemon] app crashed - waiting for file changes before starting...
I have tried every single solution I was able to find regarding this issue, including installing at least a dozen different packages using NPM. I am at a loss. Any ideas?

Resources