Hi Dennis. 1. My account has the Superuser and Create DB roles on db00. So I sudo into my account and run the following commands:
psql -d inventory => I logged in to the database psql -h 127.0.0.1 -d inventory -p 5432 => I'm logged in again psql -h 192.168.2.101 -d inventory -p 5432 => I'm logged in again psql -h 10.0.2.15 -d inventory -p 5432 => I'm logged in again 2. Here is what happens when I run the other commands from web00: psql -h 192.168.2.101 -d inventory -p 5432. => Connection refused nmap 192.168.2.101 -p 5432 Starting... Host is up... PORT STATE. SERVICE 5432/tcp. closed. postgresql Clearly, nmap "STATE closed" confirms that connections are being rejected. Regarding the forwarded_ports setting, my first question would be, in a situation like this were you have a postgresql client (my web00) inside a Vagrant VM and the server inside a second Vagrant VM, is it strictly necessary to include the :forwarded_port directive inside the Vagrantfile? Are any other settings required? And if so, how does one set the guest and host ports? The way I did it in my original question, setting Guest (db00) to 5432 and Host (web00) to 15432 didn't work. And if I set the both to 5432, that raised a different error by Vagrant. This really does seem like a Vagrant issue because I have two live servers that I configured using the same Ansible playbooks that I configured these two VMs with and I don't have this problem with my live web server talking to my database server. I'll continue to drill down into possible causes for this connection error but, again, this feels like a Vagrant issue. And yet I've already read a number of questions and blog posts regarding running postgresql on Vagrant and they all indicated that I just need the postgresql.conf and pg_hba.conf settings that I described in my original question above. This is very strange! On Tuesday, June 4, 2019 at 8:53:41 PM UTC-7, Dennis Chang wrote: > > Hi Robert, > > It does sound like your host (laptop/desktop) has a Postgres running and > therefore won't allow you to use port 5432 (on the host). > > I would suggest you take it step by step. > > 1. Can you use psql locally on db00 host? > So vagrant ssh into the db00 host and try all the commands: > > psql > psql -h 127.0.0.1 -p 5432 # loopback interface > psql -h 192.168.2.101 -p 5432 # private interface > psql -h 10.0.2.15 -p 5432 # NAT'ed interface > > 2. If the first step checks out (step #1 is about verifying that postgres > is listening on port 5432 and will accept connections on all interfaces, > i.e. 0.0.0.0) > vagrant ssh into the web00 host and run > > psql -h 192.168.2.101 -p 5432 > > You can also try: > > nmap 192.168.2.101 # in order to test that web00 can scan db00 and can > detect a port open on 5432 > > 3. Now, you can try from the host > > psql -h 192.168.2.101 -p 5432 > psql -h 10.0.2.15 -p 5432 > > > You are probably very close and there's something we're missing. Hopefully > performing these steps will help you flush it out. > Dennis > -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/vagrant/issues IRC: #vagrant on Freenode --- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/350f405c-143d-4671-89c1-1374c8214b99%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
