abernier/mosaico-backend

Database connection error when running "npm run dev"

Opened this issue · 9 comments

yudhk commented

so everything was fine until the database connection I'am using postgresql 11.2 os : debian 9 is there any file that I have to change?

[05:27:36] Finished 'launchBrowserSync' after 247 ms
[05:27:36] Starting 'watchFiles'...
[05:27:36] Finished 'watchFiles' after 44 ms
[05:27:36] Finished 'dev' after 16 s
[IMAGES] config.images.cache true
[EMAIL] transport mailing – SUCCESS
[REDIS] connection – SUCCESS
[DATABASE] connection – ERROR
[SERVER] gracefully closing server…
waiting 1 to close
issue at server init Error: [DATABASE] connection – ERROR
at config.setup.then (/home/yudha/builder/server/index.js:630:30)
at
[SERVER] exiting process
[05:27:38] [nodemon] clean exit - waiting for changes before restart
DATABASE] connection – ERROR

Hiswe commented

You need to check the server configuration if your DB doesn't match the default.

https://github.com/goodenough/mosaico-backend/blob/master/README.md#configuration

yudhk commented

sorry but I'am a newbie and I really want to install this app on my server, I see the configuration file and it is look like this

onst config = rc('backend', {
debug: false,
forcessl: false,
host: 'localhost:3000',
database: 'postgres://localhost:5432/mosaico-backend',
redis: 'redis://localhost:6379',
emailTransport: {
host: 'localhost',
port: 1025,
},

is that mean that I have to create database and named it "mosaico-backend" and what the user and passwd are should be? because I haven't touch anything with the db configuration on my server I just installed the postgresql and go into the next step, but it says database connection error

yudhk commented

so now I trying to install this on my ubuntu server and following the instruction to install this cool app, but I still got the same error "database connection error" could you tell me what is wrong with that, and I'm sure it is not because of my postgresql/database configuration since I don't do any configuration there, or maybe there is files that I have to configured?

Hiswe commented

@yudhk For the DB you should have a mosaico-backend DB.
You have also to know on which port your DB is listening.

If it doesn't match the default configuration, you should create & edit a .backendrc (see the example file)
No need to change config.js

yudhk commented
Hiswe commented

username & password have nothing to do with Node.
You should try to connect to your DB with a client and test your credentials there.
If you can make a connection, you will just have to report your config in the backend configuration

yudhk commented

I have tried it, connect to the database with credentials and it's working fine, I don't know what I have to do next because I still got the same error, since it's just vps for testing purpose if you want to take a look on my vps server and maybe you can find what is wrong with that here are the auth : 144.202.116.161 name : root password Vs5)8vX.RgX)Zhmc I'll keep the server at least for 24 hour I put the mosaico file on /home/yudha/...

Hiswe commented

DB url should be in format

postgres://db-user:db-password@db-url:db-port/db-name

I was able to solve very similar issue by adding user 'root' to my database roles, and providing adequate permissions with the specified database.

Specifying a username that DID have access using the format above in the .backendrc-example file did not solve my issue.

Sorted it by looking at db logs