Jelastic JPS cannot pass PostgreSQL node IP to N8N environment variable

I’m working on deploying N8N using a Jelastic JPS configuration file. My issue is that the system won’t properly set the database host IP in the environment variables.

I need to pass the PostgreSQL server IP to the DB_POSTGRESDB_HOST variable using ${nodes.database[0].address} but it’s not working. The variable gets set manually through the web interface just fine, but the JPS deployment fails to assign it correctly.

Here’s my configuration:

nodes:
- nodeType: nginx
  displayName: Proxy Server
  cloudlets: 16
  nodeGroup: proxy
- image: n8nio/n8n:latest
  displayName: Workflow Engine
  cloudlets: 16
  nodeGroup: app
  links: database:db
  env:
    N8N_AUTH_ACTIVE: true
    N8N_AUTH_USER: ${globals.user_name}
    N8N_AUTH_PASSWORD: ${globals.user_pass}
    DATABASE_TYPE: postgresdb
    DATABASE_HOST: ${nodes.database[0].address}
    DATABASE_PORT: 5432
    DATABASE_USER: ${globals.user_name}
    DATABASE_PASSWORD: ${globals.user_pass}
- image: postgres:15
  cloudlets: 16
  nodeGroup: database
  displayName: Database Server
  env:
    POSTGRES_USER: ${globals.user_name}
    POSTGRES_PASSWORD: ${globals.user_pass}

I’ve tried different approaches:

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

I think the issue happens because when the environment variable gets set, the PostgreSQL container hasn’t been created yet so there’s no IP address available. How can I assign the database IP after the container is running?

Any ideas on how to fix this timing issue?

Yeah, it’s definitely the timing issue you mentioned. I hit this exact same problem deploying custom apps with Jelastic. You need onAfterInstall with setNodeGroupEnvVars to update environment variables after all containers are running. Add this to your JPS file: yaml onAfterInstall: - setNodeGroupEnvVars: nodeGroup: app vars: DATABASE_HOST: ${nodes.database[0].address} . This waits for the database container to fully initialize before assigning the IP address to your N8N app. The initial deployment will have a placeholder value, but the onAfterInstall hook updates it with the real IP. You’ll probably need to restart the app nodeGroup after setting the variables so N8N picks up the new database connection string.

try using restartNodeGroup in your onAfterInstall events. it restarts the app containers right after the database is deployed, allowing IP vars to be resolved correctly. had the same issue with Jelastic and this worked for me!

The issue is that Jelastic processes environment variables during container creation, before all nodes are fully deployed. I hit this same problem with a multi-container setup last year. Using setContainerEnvVars with cmd works way better than setNodeGroupEnvVars for this situation. Add this to your JPS after the nodes section: yaml onAfterInstall: - setContainerEnvVars: nodeGroup: app vars: DATABASE_HOST: ${nodes.database[0].address} - cmd[app]: restart setContainerEnvVars targets individual containers instead of the whole node group, which is more reliable when you’re dealing with IP address timing issues. Also make sure your database container is actually listening on port 5432 before the app tries to connect.