Postgres Database Connection - "Error: Connection terminated due to connection timeout"

Hi All,

I am trying to connect to a postgres database using the node "node-red-contrib-postgresql".
A bit of context about my config :

  1. Node-red is run on an ubuntu virtual machine
  2. Postgres SQL is run on the SAME ubuntu virtual machine, and file pg_hba & postgresql.conf have been modified to accept connections from all hosts
  3. I can connect to the database through Dbeaver

Here is the simple node I am trying to execute (took from the node's documentation) :

[
    {
        "id": "82b7c689d6682f72",
        "type": "postgresql",
        "z": "42e818e1032fede2",
        "name": "ADD COLUMN",
        "query": "ALTER TABLE iot.device_data\n    DROP COLUMN IF EXISTS validity;\n\nALTER TABLE iot.device_data\n    ADD COLUMN validity BOOLEAN;\n",
        "postgreSQLConfig": "20ae1e52d1eef983",
        "split": false,
        "rowsPerMsg": "10",
        "outputs": 1,
        "x": 280,
        "y": 180,
        "wires": [
            [
                "c5f0b4b2442e3137"
            ]
        ]
    },
    {
        "id": "20ae1e52d1eef983",
        "type": "postgreSQLConfig",
        "name": "dbtestiotstore",
        "host": "20.199.13.132",
        "hostFieldType": "str",
        "port": "5432",
        "portFieldType": "num",
        "database": "iotstore",
        "databaseFieldType": "str",
        "ssl": "false",
        "sslFieldType": "bool",
        "applicationName": "",
        "applicationNameType": "str",
        "max": "10",
        "maxFieldType": "num",
        "idle": "1000",
        "idleFieldType": "num",
        "connectionTimeout": "10000",
        "connectionTimeoutFieldType": "num",
        "user": "hamza",
        "userFieldType": "str",
        "password": "HBmdp123456789*",
        "passwordFieldType": "str"
    }
]

here is the error I get :
Screen Shot 2023-04-23 at 12.38.08 AM

I have tried changing the host to localhost & 127.0.0.1, but still without luck.

Happy to get your insights

Thanks,
HB

What connection parameters do you use for that?

How did you you install node red?

Hi,

To connect to dBeaver, I use the same parameters as the one I inputted in the node settings. The host being the IP address of my VM, port 5432, No SSL, name of my db & username + password.

I installed node-red following this guide : Running on Microsoft Azure : Node-RED

@Colin If you want I can give you access to the VM & Databse in private message, as this is a test setup for now, so nothing critical in there for the moment.

Thanks,
HB

Please tell us what they are (not by looking at the node config but by looking at what you do in dBeaver). Typos are a very common problem in such cases. Don't tell us the user and pwd obviously.
Are you running dBeaver in the vm?

In the vm can you not use localhost to access the db?

How?

Does it work if you use localhost?

Does it work if you connect from your desktop using node-red?

Yes in the configuration file I allowed it to listen to all "*" for test purposes.
You can connect using localhost if in the same network yes
Does it work if you connect from your desktop using node-red? don't understand what you mean

Managed to make it work, the typo was in the config file :sweat_smile:

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