Accessing to the database from outside the container


(Martial) #1

How can i access to the database from ouside the container but in the same server (local)

I open the port in app.yml

expose:
  - "4002:5432" #postgres

Try to connect from outside with

psql -h 127.17.0.1 -p 4002 -d postgres -U postgres -p ''
psql: could not connect to server: Connection refused
        Is the server running on host "127.17.0.1" and accepting
        TCP/IP connections on port 5432?

What i’m missing ?


(Matt Palmer) #2

Did you rebuild the container after editing app.yml? That’s necessary to make changes effective in the running system.


(Martial) #3

Yep multiple time ! :weary:


(Matt Palmer) #4

I can’t reproduce the problem. If I do what you describe, it Works For Me. Presumably there’s some other sort of customisation you’ve applied, but not mentioned, that’s causing the problem.

Incidentally, since you’re running on the same machine, you don’t have to expose the port, you can just connect to the Docker-internal IP (172.17.0.<X>) on port 5432 and it should work.


(Martial) #5

Hum, the only custom thing i made is using the tutorial to add nginx and Discourse

Maybe i need to configure something into postgresql config na ?


(Joshua Rosenfeld) #6

No help on accessing the database, but you need to change your SMTP password immediately, as you just shared it publically on the internet.


PSA: Always scrub files of sensitive details before sharing!