Problem
In general, there have been a ton of issues in connecting a remote service to a PostgreSQL database. The documentation for most services doesn't really have documentation for this since the task of connecting to a PostgreSQL database requires the Admin to modify both the postgresql.conf and pg_hba.conf files.
The current scenario is giving AppSmith remote access to the given server.
- PostgreSQL needs to allow the following IP addresses at the pg_hba.conf:
18.223.74.85and3.131.104.27 - Research SSL Connections and if one would be required in this case
Success Criteria:
- Appsmith is able to connect to given database
- Appsmith is able to read/write data to given database
Resolution Research
- Allowing the above IP addresses to connect to the PostgreSQL database in the
pg_hba.conffile and changing thepostgresql.conffile to allow remote connections usinglistening_addresses = '*'did not resolve the issue. Appsmith is unable to connect to the database.
SSL Connection: SSL stands for Secure Sockets Layer and, in short, it's the standard technology for keeping an internet connection secure and safeguarding any sensitive data that is being sent between two systems, preventing criminals from reading and modifying any information transferred, including potential personal details.
SSL proved to be a dead-end for this issue with no resolution.
- In order to create an SSL connection, the following steps must be followed (PostgreSQL SSL documentation: https://www.postgresql.org/docs/9.1/ssl-tcp.html):
- OpenSSL needs to be installed on the host server (https://fedingo.com/how-to-install-openssl-in-ubuntu/). Determined that OpenSSL is already installed on the host server using
openssl version -a. - Following the above steps from the postgresql documentation does not produce the desired result.
- Following steps from https://www.cyberciti.biz/faq/postgresql-remote-access-or-connection/ does not work either.
- OpenSSL needs to be installed on the host server (https://fedingo.com/how-to-install-openssl-in-ubuntu/). Determined that OpenSSL is already installed on the host server using
Error in all cases on Appsmith: Failed to initialize pool: The connection attempt failed
Next-steps
- Consult with the Stackoverflow community to see if anyone else is having a similar issue.
- Similar issues have been found, but
Appsmithdocumentation and the Stackoverflow community did not have the information needed to fulfill this issue. I will post the full case to the community.
I resolved this problem using ngrok to make a tcp tunnel on your localhost.
Donwload and conifg ngrok and create a new tunnel on terminal, just run
ngrok tcp 5432at terminalAfter this, get the host/port and insert at Appsmith PostgreSQL Connection.
make sure your username/password is correct.
Image from host/port create on ngrok
Image to how config this host/port on Appsmith