Deploying a Parse Server to Heroku can't connect MongoDB

31 views Asked by At

I am trying to Deploying a Parse Server to Heroku. The problem is that I can't establish a connection to database. Not build in add-on ObjectRocket solution nor my custom ObjectRocket account with my database does not work.

I've registered ObjectRocket account separately to Heroku platform assuming I can also setup it for AWS Elastic Beanstalk, but it is a different question.

The Heroku dev center suggest to install a MongoDB add-on called MongoLab which is not exist, I think because it is an old setup which is strange as article says it Last updated June 14, 2023.

I would like to use my own ObjectRocket database I've created (NOT Add-On), but to be honest add-on setup does not work too.

The connection setup is here: enter image description here

I linked my Heroku app with my GitHub forked repository. No changes to parse-server-example was made.

The deployment of master branch was successful:

enter image description here

I've opened Heroku app setting and added variable DATABASE_URI I think this one field is enough to have as my localhost works with no issue and I see the initial message I dream of being a website. Please star the parse-server repo on GitHub! which I want to see that message on my Heroku app url too which as I understand that all deployed and configured correctly on Heroku:

enter image description here

When I am trying to open the running app I got this error:

enter image description here

the log is:

heroku logs --tail
2024-02-02T11:03:27.103971+00:00 app[web.1]: hosts: [],
2024-02-02T11:03:27.103971+00:00 app[web.1]: passives: [],
2024-02-02T11:03:27.103971+00:00 app[web.1]: arbiters: [],
2024-02-02T11:03:27.103971+00:00 app[web.1]: tags: {},
2024-02-02T11:03:27.103971+00:00 app[web.1]: minWireVersion: 0,
2024-02-02T11:03:27.103972+00:00 app[web.1]: maxWireVersion: 0,
2024-02-02T11:03:27.103972+00:00 app[web.1]: roundTripTime: -1,
2024-02-02T11:03:27.103972+00:00 app[web.1]: lastUpdateTime: 1952415020,
2024-02-02T11:03:27.103972+00:00 app[web.1]: lastWriteDate: 0,
2024-02-02T11:03:27.103975+00:00 app[web.1]: error: MongoNetworkError: connect ECONNREFUSED 212.64.156.191:43409
2024-02-02T11:03:27.103976+00:00 app[web.1]: at connectionFailureError (/app/node_modules/parse-server/node_modules/mongodb/lib/cmap/connect.js:387:20)
2024-02-02T11:03:27.103976+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/parse-server/node_modules/mongodb/lib/cmap/connect.js:310:22)
2024-02-02T11:03:27.103976+00:00 app[web.1]: at Object.onceWrapper (node:events:632:26)
2024-02-02T11:03:27.103977+00:00 app[web.1]: at Socket.emit (node:events:517:28)
2024-02-02T11:03:27.103977+00:00 app[web.1]: at emitErrorNT (node:internal/streams/destroy:151:8)
2024-02-02T11:03:27.103977+00:00 app[web.1]: at emitErrorCloseNT (node:internal/streams/destroy:116:3)
2024-02-02T11:03:27.103977+00:00 app[web.1]: at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
2024-02-02T11:03:27.103977+00:00 app[web.1]: cause: Error: connect ECONNREFUSED 212.64.156.191:43409
2024-02-02T11:03:27.103977+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
2024-02-02T11:03:27.103978+00:00 app[web.1]: errno: -111,
2024-02-02T11:03:27.103978+00:00 app[web.1]: code: 'ECONNREFUSED',
2024-02-02T11:03:27.103978+00:00 app[web.1]: syscall: 'connect',
2024-02-02T11:03:27.103978+00:00 app[web.1]: address: '212.64.156.191',
2024-02-02T11:03:27.103978+00:00 app[web.1]: port: 43409
2024-02-02T11:03:27.103979+00:00 app[web.1]: },
2024-02-02T11:03:27.103979+00:00 app[web.1]: [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
2024-02-02T11:03:27.103979+00:00 app[web.1]: },
2024-02-02T11:03:27.103979+00:00 app[web.1]: topologyVersion: null,
2024-02-02T11:03:27.103979+00:00 app[web.1]: setName: null,
2024-02-02T11:03:27.103980+00:00 app[web.1]: setVersion: null,
2024-02-02T11:03:27.103980+00:00 app[web.1]: electionId: null,
2024-02-02T11:03:27.103980+00:00 app[web.1]: logicalSessionTimeoutMinutes: null,
2024-02-02T11:03:27.103980+00:00 app[web.1]: primary: null,
2024-02-02T11:03:27.103980+00:00 app[web.1]: me: null,
2024-02-02T11:03:27.103981+00:00 app[web.1]: '$clusterTime': null
2024-02-02T11:03:27.103981+00:00 app[web.1]: },
2024-02-02T11:03:27.103981+00:00 app[web.1]: 'lon5-c14-2.mongo.objectrocket.com:43409' => ServerDescription {
2024-02-02T11:03:27.103981+00:00 app[web.1]: address: 'lon5-c14-2.mongo.objectrocket.com:43409',
2024-02-02T11:03:27.103981+00:00 app[web.1]: type: 'Unknown',
2024-02-02T11:03:27.103981+00:00 app[web.1]: hosts: [],
2024-02-02T11:03:27.103982+00:00 app[web.1]: passives: [],
2024-02-02T11:03:27.103982+00:00 app[web.1]: arbiters: [],
2024-02-02T11:03:27.103982+00:00 app[web.1]: tags: {},
2024-02-02T11:03:27.103982+00:00 app[web.1]: minWireVersion: 0,
2024-02-02T11:03:27.103982+00:00 app[web.1]: maxWireVersion: 0,
2024-02-02T11:03:27.103982+00:00 app[web.1]: roundTripTime: -1,
2024-02-02T11:03:27.103985+00:00 app[web.1]: lastUpdateTime: 1952415019,
2024-02-02T11:03:27.103985+00:00 app[web.1]: lastWriteDate: 0,
2024-02-02T11:03:27.103985+00:00 app[web.1]: error: MongoNetworkError: connect ECONNREFUSED 212.64.156.192:43409
2024-02-02T11:03:27.103986+00:00 app[web.1]: at connectionFailureError (/app/node_modules/parse-server/node_modules/mongodb/lib/cmap/connect.js:387:20)
2024-02-02T11:03:27.103986+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/parse-server/node_modules/mongodb/lib/cmap/connect.js:310:22)
2024-02-02T11:03:27.103986+00:00 app[web.1]: at Object.onceWrapper (node:events:632:26)
2024-02-02T11:03:27.103986+00:00 app[web.1]: at Socket.emit (node:events:517:28)
2024-02-02T11:03:27.103986+00:00 app[web.1]: at emitErrorNT (node:internal/streams/destroy:151:8)
2024-02-02T11:03:27.103987+00:00 app[web.1]: at emitErrorCloseNT (node:internal/streams/destroy:116:3)
2024-02-02T11:03:27.103987+00:00 app[web.1]: at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
2024-02-02T11:03:27.103987+00:00 app[web.1]: cause: Error: connect ECONNREFUSED 212.64.156.192:43409
2024-02-02T11:03:27.103987+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
2024-02-02T11:03:27.103987+00:00 app[web.1]: errno: -111,
2024-02-02T11:03:27.103988+00:00 app[web.1]: code: 'ECONNREFUSED',
2024-02-02T11:03:27.103988+00:00 app[web.1]: syscall: 'connect',
2024-02-02T11:03:27.103988+00:00 app[web.1]: address: '212.64.156.192',
2024-02-02T11:03:27.103989+00:00 app[web.1]: port: 43409
2024-02-02T11:03:27.103989+00:00 app[web.1]: },
2024-02-02T11:03:27.103989+00:00 app[web.1]: [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
2024-02-02T11:03:27.103989+00:00 app[web.1]: },
2024-02-02T11:03:27.103989+00:00 app[web.1]: topologyVersion: null,
2024-02-02T11:03:27.103989+00:00 app[web.1]: setName: null,
2024-02-02T11:03:27.103990+00:00 app[web.1]: setVersion: null,
2024-02-02T11:03:27.103990+00:00 app[web.1]: electionId: null,
2024-02-02T11:03:27.103990+00:00 app[web.1]: logicalSessionTimeoutMinutes: null,
2024-02-02T11:03:27.103990+00:00 app[web.1]: primary: null,
2024-02-02T11:03:27.103990+00:00 app[web.1]: me: null,
2024-02-02T11:03:27.103991+00:00 app[web.1]: '$clusterTime': null
2024-02-02T11:03:27.103991+00:00 app[web.1]: }
2024-02-02T11:03:27.103991+00:00 app[web.1]: },
2024-02-02T11:03:27.103991+00:00 app[web.1]: stale: false,
2024-02-02T11:03:27.103991+00:00 app[web.1]: compatible: true,
2024-02-02T11:03:27.103991+00:00 app[web.1]: heartbeatFrequencyMS: 10000,
2024-02-02T11:03:27.103992+00:00 app[web.1]: localThresholdMS: 15,
2024-02-02T11:03:27.103992+00:00 app[web.1]: setName: 'e48e7c08ec7f43df9fbff04459a90177',
2024-02-02T11:03:27.103992+00:00 app[web.1]: maxElectionId: null,
2024-02-02T11:03:27.103993+00:00 app[web.1]: maxSetVersion: null,
2024-02-02T11:03:27.103993+00:00 app[web.1]: commonWireVersion: 0,
2024-02-02T11:03:27.103993+00:00 app[web.1]: logicalSessionTimeoutMinutes: null
2024-02-02T11:03:27.103993+00:00 app[web.1]: },
2024-02-02T11:03:27.103994+00:00 app[web.1]: code: undefined,
2024-02-02T11:03:27.103994+00:00 app[web.1]: [Symbol(errorLabels)]: Set(0) {}
2024-02-02T11:03:27.103994+00:00 app[web.1]: }
2024-02-02T11:03:27.103994+00:00 app[web.1]: 
2024-02-02T11:03:27.103994+00:00 app[web.1]: Node.js v18.19.0
2024-02-02T11:03:27.119504+00:00 app[web.1]: npm notice
2024-02-02T11:03:27.119505+00:00 app[web.1]: npm notice New minor version of npm available! 10.2.3 -> 10.4.0
2024-02-02T11:03:27.119505+00:00 app[web.1]: npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.4.0>
2024-02-02T11:03:27.119509+00:00 app[web.1]: npm notice Run `npm install -g [email protected]` to update!
2024-02-02T11:03:27.119509+00:00 app[web.1]: npm notice
2024-02-02T11:03:27.196946+00:00 heroku[web.1]: Process exited with status 1
2024-02-02T11:03:27.223853+00:00 heroku[web.1]: State changed from starting to crashed
2024-02-02T11:03:29.262477+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=heroku-app-parse-310734064509.herokuapp.com request_id=f405f378-c2b7-43c9-9976-b136bac48b67 fwd="79.117.228.140" dyno= connect= service= status=503 bytes= protocol=https
2024-02-02T11:04:10.720909+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=heroku-app-parse-310734064509.herokuapp.com request_id=8532e9e5-ab7a-456d-8ab7-f22bc0b5d97c fwd="79.117.228.140" dyno= connect= service= status=503 bytes= protocol=https

I also tried to connect mongodb from terminal but it returns connection error also:

heroku % mongo "mongodb://user:[email protected]:43409,lon5-c14-1.mongo.objectrocket.com:43409,lon5-c14-2.mongo.objectrocket.com:43409/mymongodb?replicaSet=e48e7c08ec7f43df9fbff04459a90177"
MongoDB shell version v5.0.21
connecting to: mongodb://lon5-c14-0.mongo.objectrocket.com:43409,lon5-c14-1.mongo.objectrocket.com:43409,lon5-c14-2.mongo.objectrocket.com:43409/mymongodb?compressors=disabled&gssapiServiceName=mongodb&replicaSet=e48e7c08ec7f43df9fbff04459a90177
{"t":{"$date":"2024-02-02T11:08:00.127Z"},"s":"I",  "c":"NETWORK",  "id":4333208, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout","attr":{"replicaSet":"e48e7c08ec7f43df9fbff04459a90177","error":"FailedToSatisfyReadPreference: Could not find host matching read preference { mode: \"nearest\" } for set e48e7c08ec7f43df9fbff04459a90177"}}
Error: Could not find host matching read preference { mode: "nearest" } for set e48e7c08ec7f43df9fbff04459a90177, e48e7c08ec7f43df9fbff04459a90177/lon5-c14-0.mongo.objectrocket.com:43409,lon5-c14-1.mongo.objectrocket.com:43409,lon5-c14-2.mongo.objectrocket.com:43409 :
connect@src/mongo/shell/mongo.js:372:17
@(connect):2:6
exception: connect failed
exiting with code 1
0

There are 0 answers