Self-hosting your Moralis server

Hello,

I was able to build and start Cloud Functions on my self-hosted server. However, when I query from database (which is on Cloud MongoDB), I always receive empty data. For your information, I have imported data from my current Moralis MongoDB, and checked for the correct table name.

For example

var query = new Parse.Query(‘RBRoosterStats’);
var rows = await query.find();

rows is always empty, while this table has data.

Is there any difference in querying database for self-hosted server?

in the sample moralis-client, I see that when I update profile, it saves info to the “test” database. Is there any place where I can configure the database name?

it should work without issues, now that you self hosted you can also try to connect directly to mongo db to see if it works

maybe there are some differences when you imported the data?

the tables has to be in parse database, maybe it also requires a schema, did you also installed parse dashboard?

maybe you can change the script directly? I would expect it to use parse database and with the same table

you can also dump the database and load it using mongo dump and mongo restore

I try to name the database “parse” but no success. Table Names are the same. (I import data using JSON file, so it does not affect the schema)

I’m using the parse server downloaded from the document (https://docs.moralis.io/docs/run-parse-server-locally-1). In this example, the MongoDB URI is configured via DATABASE_URI variable in .env. I’ve tested this URI and can connect to the database using MongoDB compass.

So what do you mean by “try to connect directly to mongo db”?

and what is “parse dashboard”?

Thanks

parse dashboard is an interface for parse server, a separate component that you can install and run, it is what you see in the database dashboard for a moralis server

with compass you can see the tables and everything is fine?

when I refer to schema, there is a separate table that describes the schema for the other tables (this is specific to parse server)

if you create a document in cloud code (you can use a different table name) then everything works as expected when you try to query it?

Thanks. I see the parse dashboard github

  • With compass, I can see tables and data correctly.
  • I have imported the _SCHEMA table
  • No, I cannot create a document. It seems the cloud functions cannot connect to the right database/collections

I think the server is working but I am getting this error for the marketplaceBoilerPlate app

I checked my files I don’t see a tsconfig.json file…
image

This doesn’t seem related to the use of self-hosted servers, please make a new thread.

Hi @cryptokid

So I discover that, the demo parse server always point to “test” database. If I try to create a document, it insert into the collection in the “test” database.

How do I configure and change the database name to my wanted one?

Best regards

Can you post your .env file? You can hide the API key and username:password parts.

It should be similar to the one in this video.

Here it is

DATABASE_URI needs parse (or the database name you want) after mongodb.net e.g. ....mongodb.net/parse?retryWrites...

That’s true. Thanks a lot!!!

Hello,

I got another problem with Redis. Once in a while, the parse server stops and shows this error

Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted ‘error’ event on RedisClient instance at:
at RedisClient.on_error (/…/parse-server-migration/node_modules/redis/index.js:342:14)
at TLSSocket. (/…/parse-server-migration/node_modules/redis/index.js:223:14)
at TLSSocket.emit (node:events:513:28)
at TLSSocket.emit (node:domain:489:12)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -54,
code: ‘ECONNRESET’,
syscall: ‘read’
}

What could be the problem?

FYI, I have Redis server on render.com

whats the benefits of using direct Access ?

That can be used only to directly access the database for your Moralis server, for example if you want to dump existing data or add some indexes

1 Like

You could try with a local redis, for example you could also use a docker container for redis

Hmm, I’m planning to install the parse server on render.com too, so the redis server will become “local” anyway. I will check later.

On Clouds function, when I call this function:

Parse.Web3API.native.runContractFunction

I got error “Cannot read properties of undefined (reading ‘native’)”

How to fix it?

Thanks a lot