I'm a relative noob w.r.t. many of the moving parts on the system that I'm working on, and so please pardon me for a lack of understanding in places. My question here is more about asking for debugging strategies rather than asking for a solution to the problem, as I am drawing a blank at the moment.
Current Setup
I'm running a Docker container on an EC2 instance. All instances run in my company VPC. I need to connect to a Postgres database that lives on a workstation on-premise. The Docker container is spun-up and spun-down automatically using Dokku, an open source Heroku-alternative that I finally figured out how to get setup on EC2.
Some variables I will be using in the post:
DBSERVER
: The address of the workstation that is hosting our database.DOKKUSERVER
: The address of the Dokku EC2 instance.APPCONTAINER
: The Docker container, spun up by Dokku, that houses my app.APPNAME
: The application name on Dokku
What works
When I enter into the APPCONTAINER
with dokku enter APPNAME
, I can ping DBSERVER
and get back a response:
(environment_name) [root@APPCONTAINER project]# ping DBSERVER
PING DBSERVER (DB_SERVER_IP) 56(84) bytes of data.
64 bytes from DBSERVER (DB_SERVER_IP): icmp_seq=1 ttl=117 time=95.9 ms
64 bytes from DBSERVER (DB_SERVER_IP): icmp_seq=2 ttl=117 time=96.2 ms
64 bytes from DBSERVER (DB_SERVER_IP): icmp_seq=3 ttl=117 time=95.7 ms
What doesn't work
However, when I try to connect using pgcli
, I find I cannot connect:
(environment_name) [root@APPCONTAINER project]# pgcli -h $DB_SERVER -p $DB_PORT -U $DB_USER -d $DB_NAME
could not send SSL negotiation packet: Resource temporarily unavailable
Additionally, from my Python app, in which we use both psycopg2
and sqlalchemy
(in different parts of the codebase), I find we cannot connect to the database. On the other hand, connection from my local machine (i.e. my laptop, or another workstation that is on-premise) works without issue.
My main problem here is that the Python app requires a connection to the database via psycopg2
and sqlalchemy
, but that isn't working.
Current hypotheses
To recap, I am drawing a blank here on how to debug, and so I'm asking for debugging strategies (i.e. what should I look at) with hopefully some pointers to docs on how to debug. (Exact commands - I am happy to look them up, if pointed to the docs pages.) Things I have thought of, but am not sure how to look at, are:
- Debugging "the connection" (still a nebulous term in my head) between the Docker container on EC2 and the on-premise workstation?
Things I have done already are:
- checking to ensure that environment variables are set correctly
- ensuring that ports are set correctly for the app to work
- entering into the Docker container that Dokku is running and checking that the source code is correct.
Are there other debugging strategies that I might have missed? I would love to be enlightened on them please!