'flask_sqlalchemy keeps trying to connect to localhost database instead of the remote one

I'm trying to use the flask_sqlalchemy library in order to connect to a PostgreSQL server on my remote Ubuntu machine, but my app keeps trying to connect to the localhost database instead of the remote one. I don't have got any databases installed locally and there is no difference what I put in the SQLALCHEMY_DATABASE_URI variable.

All similar questions have no answer on stack overflow, so I despaired, guys.

Thx in advance!

Here is my config (I'm running it on MacOS):

import os
import connexion
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow

basedir = os.path.abspath(os.path.dirname(__file__))

connex_app = connexion.App(__name__, specification_dir=basedir)

app = connex_app.app

app.config["SQLALCHEMY_ECHO"] = False
app.config[
    "SQLALCHEMY_DATABASE_URI"
] = "postgresql://login:password@serverIP:port/dbName"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

db = SQLAlchemy(app)

ma = Marshmallow(app)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source