Staging Environment Agent Unreachable


Observed behavior

When I run npm start and navigate to my Production, Test, and Development environments, I can see the data displaying properly. However, the Staging environment does not work and returns the page like the first image above.

Expected behavior

The Staging environment displays the data properly like the rest of the environments.

Failure Logs

I cannot see any errors on the console. The image below is a snapshot of my devtools.

Context

  • Project name: charitywater
  • Team name: Charity Water
  • Environment name: Staging
  • Agent (forest package) name & version: forest-express-sequelize: ^8.4.8
  • Database type: postgresql hosted on AWS EC2 instance

Hi @aellxx and welcome in our community :champagne: !

Do you have any server logs ?
Could you try to access in your browser https://portal-staging-chartywater.org/forest ?

Hi Vince! I am a colleague of Ael’s. We were able to resolve the “Agent Unreachable” error and https://portal-staging-charitywater.org/forest/healthcheck returns a 200.

Here is a snippet of the logs from our Amazon EC2 instance that is hosting the backend:

GET /forest/organizations/count?fields%5Borganizations%5D=name%2CorgType%2CparentId%2CisActive&fields%5BparentId%5D=name&timezone=America%2FNew_York 500 107 - 2041.375 ms
GET /forest/organizations?timezone=America%2FNew_York&fields%5Borganizations%5D=name%2CorgType%2CparentId%2CisActive&fields%5BparentId%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=15&sort=-id 500 107 - 2200.310 ms
GET / 200 10026 - 0.950 ms
GET / 200 10026 - 2.804 ms
GET / 200 10026 - 1.325 ms
GET / 200 10026 - 1.862 ms
GET / 200 10026 - 0.921 ms
GET / 200 10026 - 0.999 ms
[forest] 🌳🌳🌳  Unexpected error: Connection terminated unexpectedly
{
  "name": "SequelizeConnectionError",
  "parent": {},
  "original": {},
  "stack": "SequelizeConnectionError: Connection terminated unexpectedly\n    at /root/portal/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:186:20\n    at Connection.<anonymous> (/root/portal/node_modules/pg/lib/client.js:284:11)\n    at Object.onceWrapper (node:events:641:28)\n    at Connection.emit (node:events:527:28)\n    at Socket.<anonymous> (/root/portal/node_modules/pg/lib/connection.js:62:10)\n    at Socket.emit (node:events:527:28)\n    at TCP.<anonymous> (node:net:715:12)"
}
[forest] 🌳🌳🌳  Unexpected error: Connection terminated unexpectedly
{
  "name": "SequelizeConnectionError",
  "parent": {},
  "original": {},
  "stack": "SequelizeConnectionError: Connection terminated unexpectedly\n    at /root/portal/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:186:20\n    at Connection.<anonymous> (/root/portal/node_modules/pg/lib/client.js:284:11)\n    at Object.onceWrapper (node:events:641:28)\n    at Connection.emit (node:events:527:28)\n    at Socket.<anonymous> (/root/portal/node_modules/pg/lib/connection.js:62:10)\n    at Socket.emit (node:events:527:28)\n    at TCP.<anonymous> (node:net:715:12)"
}
GET /forest/organizations/count?fields%5Borganizations%5D=name%2CorgType%2CparentId%2CisActive&fields%5BparentId%5D=name&timezone=America%2FNew_York 500 107 - 39885.674 ms
GET /forest/organizations?timezone=America%2FNew_York&fields%5Borganizations%5D=name%2CorgType%2CparentId%2CisActive&fields%5BparentId%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=15&sort=-id 500 107 - 40043.846 ms

We’ve checked the security groups in AWS and the access to the postgres db is configured correctly. However there seems to be timeouts and recurring SequelizeConnectionErrors. Do you have any ideas of what could be going on?

Thanks,

Jenn

Staff Edit: Remove authentication req/res from logs

IMO, this looks like your EC2 instance does not have connectivity to the database.
Where is the database hosted? On AWS RDS?

This can happen for many different reasons which are not related to forestadmin (bad vpc configuration, firewalls, …)

An easy way to check that my hunch is right:

  • SSH into the EC2 instance
  • Try to ping the database from the shell
  • Use psql to check for connectivity

If that does not work, you should review your AWS configuration