Jelastic JPS manifest fails to resolve PostgreSQL node IP for N8N environment variable

I’m working on deploying N8N using a Jelastic JPS template and running into an issue with environment variable resolution. The DB_POSTGRESDB_HOST variable needs to contain the IP address of my PostgreSQL database node, but Jelastic isn’t properly setting this value during deployment.

Here’s my current JPS configuration:

type: install
id: workflow-automation
version: 1.2
name: Workflow Engine Setup
globals:
  db_username: workflow-${fn.random(999)}
  db_password: ${fn.password}
  secret_key: app${fn.password}

nodes:
- nodeType: nginx
  displayName: Proxy Server
  cloudlets: 12
  nodeGroup: lb
- image: n8nio/n8n:latest
  displayName: Workflow Engine
  cloudlets: 12
  nodeGroup: app
  links: database:dblink
  env:
    N8N_BASIC_AUTH_ACTIVE: true
    N8N_BASIC_AUTH_USER: ${globals.db_username}
    N8N_BASIC_AUTH_PASSWORD: ${globals.db_password}
    N8N_ENCRYPTION_KEY: ${globals.secret_key}
    DB_TYPE: postgresdb
    DB_POSTGRESDB_DATABASE: workflow
    DB_POSTGRESDB_HOST: ${nodes.database[0].address}
    DB_POSTGRESDB_PORT: 5432
    DB_POSTGRESDB_USER: ${globals.db_username}
    DB_POSTGRESDB_PASSWORD: ${globals.db_password}
- image: postgres:15.3
  cloudlets: 12
  nodeGroup: database
  displayName: Database Server
  env:
    POSTGRES_USER: ${globals.db_username}
    POSTGRES_PASSWORD: ${globals.db_password}
    POSTGRES_DB: workflow

I’ve attempted different syntax variations:

DB_POSTGRESDB_HOST: ${nodes.database[0].address}
DB_POSTGRESDB_HOST: ${nodes.database.first.address}
DB_POSTGRESDB_HOST: ${nodes.database.master.address}

The core issue seems to be timing related. When the environment variables are being processed, the PostgreSQL container hasn’t been created yet, so there’s no IP address to reference. The variable only gets populated correctly when I manually set it through the Jelastic dashboard after deployment.

How can I ensure the database node IP gets properly assigned to this environment variable during the automated deployment process?

I hit the same issue deploying multi-tier apps on Jelastic. The problem is node references in environment variables get evaluated right when nodes are created, before containers are actually running. Here’s what worked for me - combine both approaches but add a startup script in your N8N container that waits for the database before starting the app. Use a custom startup command that loops connection tests until PostgreSQL responds, then launches N8N. This fixes both the IP resolution timing and prevents crashes if there’s any delay in database startup. You can also throw a sleep 30 in the onAfterInstall action before setting environment variables to give everything time to boot up.

Yeah, this is a classic sequencing issue with Jelastic deployments. Environment variables get resolved when nodes are created, but the referenced nodes don’t exist yet. I’ve hit this exact problem with multi-container apps. Skip the environment variables for database connection setup and use the onAfterInstall action instead. Use setNodeGroupEnvVars to update your N8N container’s environment after everything’s running:

onAfterInstall:
  - setNodeGroupEnvVars:
      nodeGroup: app
      vars:
        DB_POSTGRESDB_HOST: ${nodes.database[0].address}

This way PostgreSQL gets fully initialized before trying to resolve its IP. The environment variable gets set properly and N8N restarts automatically with the new config. I’ve used this pattern tons of times when containers depend on each other in Jelastic.

Another option: use service discovery instead of hardcoded IPs. Try DB_POSTGRESDB_HOST: dblink since you’ve already got the link in your nodes config. Jelastic automatically creates internal DNS entries for linked containers, so n8n can resolve the database hostname without needing the actual IP.