postgres server running in local host, but postico, metasploit can't access to it Ask Question

678 Views Asked by At

I just bought a new MacBook Pro (Catalina 10.15.5) and used Time Machine of my old MacBook that was using the same OS (10.15.5) and the transfer went fine but now when using Postico for the first time, I can't connect to localhost. I get an error.

    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

I show that I have postgressql install, or at least in my brew list. I'm not sure if I need to run this command initdb /usr/local/var/postgres on the new MacBook since I pretty much copy the HDD in my old MacBook in Recovery Mode on my new one?

Could that by the problem Postico not able to connect to localhost on my new Mac? I also use Metasploit and I get a connection error too.

[-] * WARNING: No database support: could not connect to server: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?

[-] ***

Right now, I'm just looking to fix Postico problem and any postgressql issues. I'll figure out the metasploit problem later.

1

There are 1 best solutions below

0
On

Don't run initdb at this time. It will refuse to run if there are files in the $PGDATA directory anyway. You need to check if the server is actually running. See this SO answer for more information: How to start PostgreSQL server on Mac OS X?

If the server is running then check postgresql.conf for what listen_addresses is set to: https://www.postgresql.org/docs/12/runtime-config-connection.html

To rule out hosts issues try connecting with -h 127.0.0.1 or ::1 if you have not already.