# Staging Environment Agent Unreachable

**URL:** <https://community.forestadmin.com/t/staging-environment-agent-unreachable/6408>\
**Category:** Help me!\
**Tags:** setup, agent\
**Created:** [June 15, 2023, 8:45pm UTC](https://community.forestadmin.com/t/staging-environment-agent-unreachable/6408 "2023-06-15T20:45:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aellxx](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/aellxx/32/6234_2.png) [@aellxx](https://community.forestadmin.com/u/aellxx)\
**Post date:** [June 15, 2023, 8:45pm UTC](https://community.forestadmin.com/t/staging-environment-agent-unreachable/6408/1 "2023-06-15T20:45:59Z")

</div>

![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/a/aa7ea4df8034d59694dfa66bddda17a8a12767e3.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/f/f952fa054fdb88c05591806f9b7294e671ae12f9.png)

## 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.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/c/cd9af232244096c3ad1e381c147455375f241a96.png)

## 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

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 19, 2023, 8:18am UTC](https://community.forestadmin.com/t/staging-environment-agent-unreachable/6408/2 "2023-06-19T08:18:32Z")

</div>

Hi @aellxx and welcome in our community 🍾 !

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

---

<div class="post-metadata">

**Author:** ![jenn.proos](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jenn.proos](https://community.forestadmin.com/u/jenn.proos)\
**Post date:** [June 28, 2023, 1:10pm UTC](https://community.forestadmin.com/t/staging-environment-agent-unreachable/6408/3 "2023-06-28T13:10:40Z")

</div>

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](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:

```javascript
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

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [June 30, 2023, 11:49am UTC](https://community.forestadmin.com/t/staging-environment-agent-unreachable/6408/5 "2023-06-30T11:49:06Z")

</div>

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
