I’m using flyctl proxy 5432 -a my_database
to access postgres locally using DBeaver (database application), which works fine. However, I can’t access my database from node using the pg node package. It always tells me the connection is refused, even though the same credentials work fine in a database program. Any idea what I’m doing wrong? It’s going to be very difficult to develop if I have to deploy changes to test.
In case anyone else runs into this, I finally figured out that instead of using ‘localhost’ for the server I had to use ‘127.0.0.1’ and it magically started working. That was very frustrating to track down.
Strange. On my app’s VMs, localhost
does point to 127.0.0.1
➜ fly ssh console -s -a myapp
Connecting to [fdaa:0:dead:beef:dead:beef:dead:2]... complete
# grep "localhost" /etc/hosts
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
127.0.0.1 localhost localhost4
::1 localhost localhost6
# nslookup localhost
Server: fdaa::3
Address: [fdaa::3]:53
Name: localhost
Address: ::1
Name: localhost
Address: 127.0.0.1
It could be the base container you’re using? My app’s on Alpine.