Joplin server with custom database port

The Joplin Server topic suggests creating a separate topic for support questions, so here goes.

I'm wanting to run Joplin Server on a CentOS 7 server using the provided docker-compose file. That server has an existing Postgres 9 installation listening on port 5432, so I need to have Joplin's Postgres instance listen on a different port, like 5433. I figured this would be pretty straightforward, just edit .env to read:

POSTGRES_PORT=5433

...and the docker-compose file to read:

services:
    db:
       	image: postgres:13.1
        volumes:
            - ./data/postgres:/var/lib/postgresql/data
        ports:
            - "5433:5432"

But the app container appears to be unable to communicate with the db container--I get repeated errors of:

app_1  | 2021-07-21 13:37:31: App: DB Config: {
app_1  |   client: 'pg',
app_1  |   name: 'joplin',
app_1  |   user: 'joplin',
app_1  |   password: '********',
app_1  |   port: 5433,
app_1  |   host: 'db'
app_1  | }
app_1  | 2021-07-21 13:37:31: App: Trying to connect to database...
app_1  | 2021-07-21 13:37:31: db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:5433
app_1  | 2021-07-21 13:37:32: db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:5433
app_1  | 2021-07-21 13:37:33: db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:5433
app_1  | 2021-07-21 13:37:34: db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:5433
app_1  | 2021-07-21 13:37:35: db: Could not connect. Will try again. connect ECONNREFUSED 172.18.0.2:5433

Looks like I'm missing a setting--what should I change?

Edit: I see in another topic (Self hosted server help - #2 by dpoulton) the recommendation to use a release tag for the application rather than just latest. That doesn't sound like it'd be relevant to my issue, but it seems like it could be good counsel. Unfortunately, it didn't help this problem; I continue to get the same error message. The complete docker-compose reads as:

# This is a sample docker-compose file that can be used to run Joplin Server
# along with a PostgreSQL server.
#
# All environment variables are optional. If you don't set them, you will get a
# warning from docker-compose, however the app should use working defaults.

version: '3'

services:
    db:
        image: postgres:13.1
        volumes:
            - ./data/postgres:/var/lib/postgresql/data
        ports:
            - "5433:5432"
        restart: unless-stopped
        environment:
            - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
            - POSTGRES_USER=${POSTGRES_USER}
            - POSTGRES_DB=${POSTGRES_DATABASE}
    app:
        image: joplin/server:2.2.7-beta
        depends_on:
            - db
        ports:
            - "22300:22300"
        restart: unless-stopped
        environment:
            - APP_PORT=22300
            - APP_BASE_URL=${APP_BASE_URL}
            - DB_CLIENT=pg
            - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
            - POSTGRES_DATABASE=${POSTGRES_DATABASE}
            - POSTGRES_USER=${POSTGRES_USER}
            - POSTGRES_PORT=${POSTGRES_PORT}
            - POSTGRES_HOST=db

This didn't work for me either so I wondered what would happen if the port was changed for the postgres container instead.

version: '3'
services:
    db:
        restart: unless-stopped
        image: postgres:13.1
        ports:
            - "5433:5433"
        volumes:
            - /foo/bar/joplin-data:/var/lib/postgresql/data
        environment:
            - POSTGRES_PASSWORD=joplin
            - POSTGRES_USER=joplin
            - POSTGRES_DB=joplin
        command: -p 5433

and it worked! Don't know why one works and the other doesn't ...

2 Likes

Thanks for the suggestion, that worked for me too. It's now up and running.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.