MongoDB error while installing Rocket.chat in CentOS 8 server with Apache - node.js

I am following this tutorial to install a Rocket.chat server in CentOS:
https://hostpresto.com/community/tutorials/how-to-install-rocket-chat-server-on-centos-7/
I am new to mongodb and node.js so I am not very familiar with how all this works
At the moment I am looking for something simple that just works
When I reach the step where it says to execute
node main.js
I get the following error:
[username#localhost Rocket.chat]$ node main.js
/opt/Rocket.chat/programs/server/node_modules/fibers/future.js:313
throw(ex);
^
MongoError: not master and slaveOk=false
at Connection.<anonymous> (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:450:61)
at Connection.emit (events.js:310:20)
at processMessage (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:384:10)
at Socket.<anonymous> (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:553:15)
at Socket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
ok: 0,
errmsg: 'not master and slaveOk=false',
code: 13435,
codeName: 'NotMasterNoSlaveOk',
[Symbol(mongoErrorContextSymbol)]: {}
}
The tutorial says I should be able to see the Rocket.chat web interface if I go to https://yourdomain.com:3000 but I get an unable to connect page, which I suppose is due to the error above
The tutorial also says node main.js is to check if MongoDB is running or not. I can see that MongoDb service is running by executing
systemctl status mongod
so this error seems to be caused by something else.
How do I find out what is causing this error? Or are there any mistakes in this tutorial? I have found other tutorials regarding installing Rocket.chat in CentOS but most of them use nginx as hte web server while I need to use Apache.

Related

error: database "dbName" does not exist Node.js PostgreSQL

I'm just starting with Node.js and I'm following this tutorial https://dev.to/glaucia86/developing-a-crud-node-js-application-with-postgresql-4c9o
when setting .env file as suggested
DATABASE_URL=postgres://{db_username}:{db_password}#{host}:{port}/{db_name}
so
DATABASE_URL=postgres://vinnytwice:pass#localhost:5432/fixit
I start the server with npm start command when using Postman to send a Post request I get they error in console:
vinnytwice#Vinnys-iMac fixit_server_node % npm start
> fixit_server_node#1.0.0 start
> node server.js
App executing to port 3000
error: database "vinnytwice" does not exist
at Parser.parseErrorMessage (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:369:20)
at addChunk (node:internal/streams/readable:313:12)
at readableAddChunk (node:internal/streams/readable:288:9)
at Socket.Readable.push (node:internal/streams/readable:227:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
What am I doing wrong ?
Many thanks.
Finally found the problem, the .env file wasn't at the root of the project.

MongoNetworkError on first connect using Docker and NodeJS

I'm still incredibly new to coding. I'm trying to launch an app using docker, everything goes well until I get this error:
{ MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (/app/node_modules/mongodb/lib/core/topologies/server.js:433:11)
at Pool.emit (events.js:198:13)
at createConnection (/app/node_modules/mongodb/lib/core/connection/pool.js:577:14)
at connect (/app/node_modules/mongodb/lib/core/connection/pool.js:1007:11)
at makeConnection (/app/node_modules/mongodb/lib/core/connection/connect.js:31:7)
at callback (/app/node_modules/mongodb/lib/core/connection/connect.js:247:5)
at Socket.err (/app/node_modules/mongodb/lib/core/connection/connect.js:276:7)
at Object.onceWrapper (events.js:286:20)
at Socket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'MongoNetworkError',
[Symbol(mongoErrorContextSymbol)]: {} }
[nodemon] clean exit - waiting for changes before restart
I have mongodb running as a server on Windows 10, and I also have it running in another window, so I'm not sure what could be causing it. I've tried all solutions on this page, but to no avail. Thanks in advance!
Localhost is the container, not your machine. When working with containers, you need to think of container as a separate machine and use a full network adressess to communicate between your machine and container.
I was using a similar concept like yours. Try to run both node-app and Mongo service under the same network.
In Mongo connection string, the Hostname should be the same as your service name mentioned in docker-compose.yml file.

MongoError : command createIndexes requires authentication - mongodb npm

I have a project that I recently put in a production server (not live, but different from my development environment). I configured a mongoDB server with a password authentication.
When I start my Nodejs Application, my usual code retrieve correctly my mongoDB server, returning a client.db object successfully.
But I also have an error popping-in. Something that is not called inside my Nodejs application apparently.
[ERROR] { MongoError: command createIndexes requires authentication
at Connection.<anonymous> (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/pool.js:460:61)
at Connection.emit (events.js:189:13)
at processMessage (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/connection.js:368:10)
at Socket.<anonymous> (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/connection.js:537:15)
at Socket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
ok: 0,
errmsg: 'command createIndexes requires authentication',
code: 13,
codeName: 'Unauthorized',
name: 'MongoError',
[Symbol(mongoErrorContextSymbol)]: {} }
nothing in the error is pointing toward something I created, it's only about the mongodb npm library. It also giving this error even if a delete every MongoDB connexion related code (but not the mongodb library load).
Do you have any idea how to fix this ?
Okay it's my fault. I had another connexion point that I didn't changed from my express sessions. It's fixed now.
It's just weird the error didn't point toward that module..

No living connections Error while Elasticsearch connections in nodejs

I am having this problem while connecting the elasticsearch connections.
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({ host: 'localhost:9200',
log: 'trace'});
Elasticsearch ERROR: 2016-07-19T19:09:26Z
Error: Request error, retrying -- connect ECONNREFUSED 127.0.0.1:9200
at Log.error (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/log.js:225:56)
at checkRespForFailure (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/transport.js:195:18)
at HttpConnector. (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/connectors/http.js:154:7)
at ClientRequest.bound (/root/git_build/FirstMoveChess/node_modules/lodash-node/modern/internals/baseBind.js:56:17)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:308:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1272:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Elasticsearch TRACE: 2016-07-19T19:09:27Z
-> HEAD http://localhost:9200/
I understand this question is quite old but I wanted to share how you can solve this problem.
If you are locally using elasticsearch
First thing you must do is running elasticsearch on your machine.
Error: Request error, retrying -- connect ECONNREFUSED 127.0.0.1:9200
Because above message indicates that you're not running elasticsearch locally.
So, visit the link and follow the insturction.
Docker environment
It gets much trickier here.
First, follow the instruction here.
And in case you're using node.js elasticsearch client, you have to specify elasticsearch host as 172.24.0.1.
If you use container_name or private IP of container in docker-compose.yml, it won't work.
In case of Docker Container Environment after changing from http://localhost:9200 to http://ipaddress:9200 in docker-compose.yml
please change the following live in docker-compose.yml that is related to CORS
Change this
** http.cors.allow-origin=/https?://localhost(:[0-9]+)?/ **
into this
*- http.cors.allow-origin= **

My meanjs Application is not getting started in offline mode?

I have installed all the prerequisites for a mean application(MEAN) as described in Meanjs Official website
I want you to look at this particular error I am getting and that too when I am offline.
But it does work well when I am connected to internet.
Help me Try looking at the error below:
Could not connect to MongoDB!
Error: failed to connect to [localhost:27017]
C:\Users\ASHOK\Downloads\meanjs-mean-88a89f2\node_modules\connect-mongo\lib\connect-mongo.js:186
throw err;
^
Error: Error connecting to database: failed to connect to [localhost:27017]
at null.<anonymous> (C:\Users\ASHOK\Downloads\meanjs-mean-88a89f2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:555
:25)
at emit (events.js:118:17)
at null.<anonymous> (C:\Users\ASHOK\Downloads\meanjs-mean-88a89f2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_po
ol.js:156:15)
at emit (events.js:110:17)
at Socket.<anonymous> (C:\Users\ASHOK\Downloads\meanjs-mean-88a89f2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.
js:534:10)
at Socket.emit (events.js:107:17)
at net.js:950:16
at process._tickCallback (node.js:355:11)
[nodemon] app crashed - waiting for file changes before starting...
Did you start mongodb: try typing mongod into the terminal

Resources