Issue
I am trying to add Postgres as a data source in Appsmith, which both run on the same Docker host. However, I keep getting refused to connect errors when using the server's public IP, Docker internal IP, and localhost in the host address field. I need to know what to use as the host address for my PG data source.
Resolution
The issue is that the connection to the Postgres database is being refused when attempting to add it as a data source to Appsmith. The host address field in the data source configuration needs to be updated to "db". This is because the Postgres service is defined as "db" in the docker-compose.yml file.
Alternatively, when developing and testing, the host address can be set to "host.docker.internal" instead of localhost or an IP. However, this is not recommended for production environments.
Here is an example of updating the host address in the data source configuration:
{
"pluginId": "postgres-plugin",
"name": "my-postgres-db",
"datasourceConfiguration": {
"url": "jdbc:postgresql://db:5432/myDatabase",
"username": "fakeuser",
"password": "fakepassword"
}
}