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.
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?
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]: restartsetContainerEnvVars 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.