MongoDb Connection Error when using Mongoose - javascript

I did not have a problem connecting to Atlas previously from my wifi at home. But I have issues at Starbucks. I have now switched to google fiber and I am getting this error.
at Pool.<anonymous> (/Users/j/Desktop/projects/templateApp/node_modules/mongodb-core/lib/topologies/server.js:431:11)
at Pool.emit (events.js:182:13)
at connect (/Users/j/Desktop/projects/templateApp/node_modules/mongodb-core/lib/connection/pool.js:557:14)
at callback (/Users/j/Desktop/projects/templateApp/node_modules/mongodb-core/lib/connection/connect.js:109:5)
at runCommand (/Users/j/Desktop/projects/templateApp/node_modules/mongodb-core/lib/connection/connect.js:129:7)
at Connection.errorHandler (/Users/j/Desktop/projects/templateApp/node_modules/mongodb-core/lib/connection/connect.js:321:5)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at TLSSocket.<anonymous> (/Users/j/Desktop/projects/templateApp/node_modules/mongodb-core/lib/connection/connection.js:350:12)
at Object.onceWrapper (events.js:273:13)
at TLSSocket.emit (events.js:182:13)
at _handle.close (net.js:596:12)
at TCP.done [as _onclose] (_tls_wrap.js:383:7)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],```
I have checked my strings and they are correct.
My connection code is:
```mongoose.connect(process.env.dataBaseConnection, {
dbName: process.env.dataBaseName,
useFindAndModify: false,
useNewUrlParser: true
});```

The issue was that I needed to white list my new ip address.

Related

Strapi is giving credential errors when I try to connect it with postgresql even the credentials are correct

I have a newly created strapi app and tried to connect it with postgresql DB and I have entered the correct credentials but it gives me the errors called
[2022-05-25 09:30:24.315] debug: ⛔️ Server wasn't able to start properly.
[2022-05-25 09:30:24.330] error: password authentication failed for user "user"
error: password authentication failed for user "user"
at Parser.parseErrorMessage (C:\Users\user\OneDrive\Desktop\commerce-
strapi\myshop\node_modules\pg-protocol\dist\parser.js:287:98)
at Parser.handlePacket (C:\Users\user\OneDrive\Desktop\commerce-
strapi\myshop\node_modules\pg-protocol\dist\parser.js:126:29)
at Parser.parse (C:\Users\user\OneDrive\Desktop\commerce-
strapi\myshop\node_modules\pg-protocol\dist\parser.js:39:38)
at Socket.<anonymous> (C:\Users\user\OneDrive\Desktop\commerce-
strapi\myshop\node_modules\pg-protocol\dist\index.js:11:42)
at Socket.emit (node:events:527:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
and the database.js file is :
module.exports = ({ env }) => ({
defaultConnection: "default",
connection: {
client: 'postgres',
connection: {
host: env('DATABASE_HOST', 'localhost'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'strapi'),
username: env('DATABASE_USERNAME', 'postgres'),
password: env('DATABASE_PASSWORD', 'lokesh'),
schema: env('DATABASE_SCHEMA', 'public'), // Not required
},
},
});
I have found this database.js file for strapi v4 in a youtube video.
But even if I entered correct credentials it gives me errors I have tried restarting the server soo many time but it didn't work, can anyone help me please.

Why I get Access Denied error from Loopback4 while able to connect from MySql workbench using same credentials

I am trying to run todo list example in loopback 4. I use MySql as the backend db on a different server. The problem I am facing is while I could connect to the database from MySql Workbench, I get the following error when I try making the db connection from loopback 4 using the same credentials.
Any help is appreciated.
Connection fails: Error: ER_DBACCESS_DENIED_ERROR: Access denied for user 'dev1'#'%' to database 'todo'
It will be retried for the next request.
C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\sequences\Sequence.js:47
var err = new Error(code + ': ' + packet.message);
^
Error: ER_DBACCESS_DENIED_ERROR: Access denied for user 'dev1'#'%' to database 'todo'
at Handshake.Sequence._packetToError (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
at Handshake.ErrorPacket (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\sequences\Handshake.js:123:18)
at Protocol._parsePacket (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\Protocol.js:291:23)
at Parser._parsePacket (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\Parser.js:433:10)
at Parser.write (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\Parser.js:43:10)
at Protocol.write (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\Connection.js:91:28)
at Socket.<anonymous> (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\Connection.js:525:10)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23)
--------------------
at Protocol._enqueue (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at PoolConnection.connect (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\Connection.js:119:18)
at Pool.getConnection (C:\Users\rames\GitHub\todo-list\node_modules\mysql\lib\Pool.js:48:16)
at MySQL.connect (C:\Users\rames\GitHub\todo-list\node_modules\loopback-connector-mysql\lib\mysql.js:90:17)
at Object.initializeDataSource [as initialize] (C:\Users\rames\GitHub\todo-list\node_modules\loopback-connector-mysql\lib\mysql.js:44:28)
at DbDataSource.DataSource.setup (C:\Users\rames\GitHub\todo-list\node_modules\loopback-datasource-juggler\lib\datasource.js:513:19)
at new DataSource (C:\Users\rames\GitHub\todo-list\node_modules\loopback-datasource-juggler\lib\datasource.js:145:8)
at new DbDataSource (C:\Users\rames\GitHub\todo-list\src\datasources\db.datasource.ts:20:5)
at C:\Users\rames\GitHub\todo-list\node_modules\#loopback\context\src\resolver.ts:73:14
at Object.transformValueOrPromise (C:\Users\rames\GitHub\todo-list\node_modules\#loopback\context\src\value-promise.ts:270:12)
at Object.instantiateClass (C:\Users\rames\GitHub\todo-list\node_modules\#loopback\context\src\resolver.ts:66:35)
at C:\Users\rames\GitHub\todo-list\node_modules\#loopback\context\src\binding.ts:533:29
at Binding._getValue (C:\Users\rames\GitHub\todo-list\node_modules\#loopback\context\src\binding.ts:410:14)
at C:\Users\rames\GitHub\todo-list\node_modules\#loopback\context\src\binding.ts:305:23
at C:\Users\rames\GitHub\todo-list\node_modules\#loopback\context\src\resolution-session.ts:114:13
I noticed there was a typo in database name in the connection string. I fixed it and I am able to connect now.
#jaromanda Thank you.

Error: Invalid JSON RPC response while using INFURA

getting error:While implementing ethereum blockchain code ,
error that i am getting is :Invalid JSON RPC response while using INFURA
Attaching error log below kindly help
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/home/joshi/Desktop/inbox/node_modules/truffle-hdwallet-provider/node_modules/web3/lib/web3/errors.js:35:16)
at XMLHttpRequest.request.onreadystatechange (/home/joshi/Desktop/inbox/node_modules/truffle-hdwallet-provider/node_modules/web3/lib/web3/httpprovider.js:115:32)
at XMLHttpRequestEventTarget.dispatchEvent (/home/joshi/Desktop/inbox/node_modules/xhr2/lib/xhr2.js:64:18)
at XMLHttpRequest._setReadyState (/home/joshi/Desktop/inbox/node_modules/xhr2/lib/xhr2.js:354:12)
at XMLHttpRequest._onHttpRequestError (/home/joshi/Desktop/inbox/node_modules/xhr2/lib/xhr2.js:544:12)
at ClientRequest.<anonymous> (/home/joshi/Desktop/inbox/node_modules/xhr2/lib/xhr2.js:414:24)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
If you don't post more information, such as a little piece of code is difficult to understand what is happening.
What you should try is this:
In every link to infura api remove the "/v3" part from the url.
From this:
const provider = new HDWalletProvider(mnemonic,
'https://rinkeby.infura.io/v3/project_id');
To this:
const provider = new HDWalletProvider(mnemonic,
'https://rinkeby.infura.io/project_id');
Hope this helps.
Don't use www and /v3 in infura API URI and it's required to use https in the URI. eg.
https://rinkeby.infura.io/project_id

Postresql not connecting to heroku

im using heroku to host my site however it keeps spitting out the same error which is
2018-05-06T19:28:52.212104+00:00 app[web.1]:AssertionError [ERR_ASSERTION]: false == true
2018-05-06T19:28:52.212106+00:00 app[web.1]:at Object.exports.connect (_tls_wrap.js:1036:3)
2018-05-06T19:28:52.212107+00:00 app[web.1]: at Socket. (/app/node_modules/pg/lib/connection.js:94:23)
2018-05-06T19:28:52.212109+00:00 app[web.1]:at Object.onceWrapper (events.js:315:30)
2018-05-06T19:28:52.212110+00:00 app[web.1]:at emitOne (events.js:116:13)
2018-05-06T19:28:52.212112+00:00 app[web.1]: at Socket.emit (events.js:211:7)
2018-05-06T19:28:52.212113+00:00 app[web.1]:at addChunk (_stream_readable.js:263:12)
2018-05-06T19:28:52.212115+00:00 app[web.1]:at readableAddChunk (_stream_readable.js:250:11)
2018-05-06T19:28:52.212116+00:00 app[web.1]:at Socket.Readable.push (_stream_readable.js:208:10)
2018-05-06T19:28:52.212118+00:00 app[web.1]: at TCP.onread >>(net.js:607:20)
this is how im connecting (taken straight off of herokus website)
const { Client } = require("pg");
const router = express.Router();
const pool = new Client({
connectionString: process.env.DATABASE_URL,
ssl: true,
});
pool.connect();
I found out what the error was:
the error was that i did not have a db create. i decided to use elephantSQL and from their i connected to elephantSQL with pgadmin and recreated my database. it works perfect now
to see how this works see : https://www.elephantsql.com/docs/pgadmin.html
im more than happy to answer some questions
OK, this isn't really a solution but it might help you out. This happens to me on node 8 (and 10) but when I downgraded to node 7 it seems to work fine. I'll be watching this post to see if someone comes up with a better fix.

How can I configure sails-neo4j adapter?

I'm trying to create a simple web app using sailsjs. I'd like to use a neo4j database and I've found only this adapter: https://github.com/natgeo/sails-neo4j/
I try to add the adpter configuration in connection.js using mostly of default value (as I've a default installation):
neo4jServer: {
adapter: 'sails-neo4j'
//protocol: 'http://',
//port: 7474,
//host: 'localhost',
//base: '/db/data/',
//debug: false }
and specifing it in my model.js file:
connection: 'neo4jServer',
but I've this error (not so explicit..) if I try to lift up the server (I don't have any logic yet, I only created a couple of model using api generation):
C:\WS\SAILS\testProject\node_modules\sails-neo4j\lib\connection.js:15
throw err;
^ Error
at ClientRequest.<anonymous> (C:\WS\SAILS\testProject\node_modules\sails-neo4j\node_modules\neo4j-js\lib\Neo4jApi.js:227:13)
at ClientRequest.g (events.js:260:16)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at HTTPParser.parserOnIncomingClient (_http_client.js:415:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
at Socket.socketOnData (_http_client.js:305:20)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
Does anyone use it? How can be configured in order to make it works? I'm using sailsjs 0.11.3
Thanks,
Michele.
If using authentication with Neo4j, be sure to specify the credentials. You can do this in the host property of the config object for the sails adapter (Neo4j uses Basic Authentication):
neo4jServer: {
adapter: 'sails-neo4j'
protocol: 'http://',
port: 7474,
host: 'username:password#localhost',
base: '/db/data/',
debug: false
}
or disable Neo4j authentication by setting dbms.security.auth_enabled=false in conf/neo4j-server.properties

Categories

Resources