Hi!
I have an ubuntu lightsail server that is running a node express app and a postgres server. These were not from a template, I set these up myself, and the database is running in a docker container on the lightsail instance (this issue exists on non-docker postgres as well). I have a static IP set up. For networking, I have all TCP ports open to all IPv4 addresses.
Everything is set up and I'm able to visit my webapp at:
<myipaddress>:8080
and my database at:
<myipaddress>:5432
^that is working great.
I'm trying to get these to work with a subdomain on my site on namecheap. I added an A record with the corresponding subdomain, and the ip address.
After that^, my express app becomes reachable at subdomain.mydomain.com:8080
, but my database is not reachable via the subdomain. This single A record was enough to get this to work on an identical setup in Vultr for both my express app and my database.
When I try to connect via the subdomain I get the following error from my postgres client:
getaddrinfo ENOTFOUND subdomain.mydomain.com
After trying the A record, I applied all the NS (Name Server) records available on Domains & DNS tab. This didn't seem to have any effect on anything, from what I could tell. I have my subdomain assigned to my static ip in the assignments sub-tab.
I doubt it's a configuration issue with postgres, because it's working via the IP address directly. Would greatly appreciate any ideas.
Thanks so much!
Update:
I installed psql client, and I am able to open a connection to the database via the subdomain, not just the IP address.
Still unable to connect to the subdomain from my computer directly.
So I'm guessing it has something to do with some firewall configuration that I cannot see?
Update 2:
I installed postgres directly onto the box and tore down my docker containers. I set up the config to allow external connections.
I am still able to connect to this postgres server via IP but NOT via my custom domain. So this issue is not specifically related to docker.
Edit:
here is my compose.yaml
, same setup as my vultr vps:
version: '3'
volumes:
pgdata:
driver: local
services:
postgres:
image: postgres
environment:
POSTGRES_PASSWORD: some_password_here
ports:
- '5432:5432'
volumes:
- pgdata:/var/lib/postgresql/base
deploy:
resources:
limits:
memory: 200M