I’m having trouble with n8n in a Jelastic JPS setup. The main issue is that Jelastic isn’t picking up the DB_POSTGRESDB_HOST environment variable. I need to use ${nodes.sqldb[0].address} to get the Postgres node’s IP, but it’s not working in the JPS file. It only works when I add the variable manually through the GUI.
But none of them work. I think the problem might be that when the variable is set, the Postgres node hasn’t been created yet, so there’s no IP to assign. Does anyone know how to fix this or pass the IP to the variable after the node is created? Any help would be great!
I’ve dealt with similar challenges in Jelastic environments. One approach that’s worked well for me is using a custom initialization hook. You can create a script that runs after all nodes are deployed, fetching the Postgres IP dynamically.
This hook triggers after the SQL node is cloned, ensuring the IP is available. It then adds the environment variable to your container. You might need to adjust the node group name to match your setup.
Remember to restart your n8n service after applying this change to ensure it picks up the new environment variable. Hope this helps solve your issue!
I’ve encountered similar issues with environment variables in Jelastic JPS setups. One workaround that’s worked for me is using a post-deploy script to set the environment variable after all nodes are created. You can add a ‘postInstall’ action in your JPS file that runs a script to fetch the Postgres IP and set the DB_POSTGRESDB_HOST variable.
Here’s a rough example of what this might look like: