Cannot dial out or connect

mc6650

Member
Apr 8, 2019
90
2
8
59
Hello
Everything was working fine 4 days ago and now I can't connect via the GUI nor can I dial out. I've reset the VM instance but I get this error message when trying to login via the GUI. I can SSH into the device. I'm running FusionPBX on a Proxmox VM server.

error: SQLSTATE[08006] [7] connection to server at "localhost" :):1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?

Thanks in advance for any help that can be provided.
 

hfoster

Active Member
Jan 28, 2019
291
28
28
32
Is postgresql started?

# systemctl status postgresql

If not, try starting it.

# systemctl start postgresql
 

mc6650

Member
Apr 8, 2019
90
2
8
59
Hello
postgresql seems to be started.

pbx2@FusionPBX:~$ systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Fri 2022-08-05 09:48:31 EDT; 3h 42min ago
Process: 412 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 412 (code=exited, status=0/SUCCESS)
CPU: 1ms
pbx2@FusionPBX:~$
 

mc6650

Member
Apr 8, 2019
90
2
8
59
Update:
I was reading through some of the forum posts and I did a "netstat -nal". Don't know if that helps.

netstat -nal
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
tcp 0 288 192.168.2.10:22 192.168.2.52:57870 ESTABLISHED

I also did a "cat /etc/postgresql/13/main/postgresql.conf" and found:

# - Connection Settings -

#listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)

Again, I don't know if this helps. Thanks.
 

mc6650

Member
Apr 8, 2019
90
2
8
59
Further update:

I stopped then started the service:

root@FusionPBX:~# systemctl stop postgresql
root@FusionPBX:~# systemctl start postgresql
root@FusionPBX:~# systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Fri 2022-08-05 16:27:21 EDT; 17s ago
Process: 18070 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 18070 (code=exited, status=0/SUCCESS)
CPU: 784us

Aug 05 16:27:21 FusionPBX systemd[1]: Starting PostgreSQL RDBMS...
Aug 05 16:27:21 FusionPBX systemd[1]: Finished PostgreSQL RDBMS.
 

hfoster

Active Member
Jan 28, 2019
291
28
28
32
Well it's hard to say what's gone wrong. If you followed the standard Debian installation it shouldn't really have an issue.

Does the fusionpbx PostgreSQL credentials work? You can get them from /etc/fusionpbx/config.php and then try to access the database with:

# psql -h 127.0.0.1 -U fusionpbx -W -d fusionpbx
 

mc6650

Member
Apr 8, 2019
90
2
8
59
Initial error message

psql: error: connection to server at "127.0.0.1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?

Then I switch to su and did a:

systemctl stop postgresql

Followed by a:

systemctl start postgresql

Then a:

systemctl status postgresql

Verified the DB is running:

● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2022-08-07 17:30:09 EDT; 1min 35s ago
Process: 147613 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 147613 (code=exited, status=0/SUCCESS)
CPU: 810us

Then:

psql -h 127.0.0.1 -U fusionpbx -W -d fusionpbx

And received:

psql: error: connection to server at "127.0.0.1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?

Back to square one again. Any other suggestions? Thanks for the help.
 

hfoster

Active Member
Jan 28, 2019
291
28
28
32
Oh sorry, because of the weird way postgresql is packaged on Debian, the service is actually:

$ sudo systemctl status postgresql@13-main.service

It's possible the pg_hba.conf has been modified. It should look like, specifically the first 127.0.0.1/32 line:

Code:
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

It's possible the daemon is dead or locked up. Worth checking the logs: $ sudo cat /var/log/postgresql/postgresql-13-main.log

Looking at your netstat, it appears to be dead. That might just be netstat though, I use 'ss' instead:

Code:
hfoster@pbx:~$ sudo ss -nltp | grep postgres
LISTEN 0      244        127.0.0.1:5432      0.0.0.0:*    users:(("postgres",pid=133763,fd=6)) 
LISTEN 0      244            [::1]:5432         [::]:*    users:(("postgres",pid=133763,fd=5))
 

mc6650

Member
Apr 8, 2019
90
2
8
59
First command I used was ss -nltp | grep postgres

Returned nothing.

Then:
systemctl status postgresql@13-main.service

● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2022-08-07 17:30:09 EDT; 1min 35s ago
Process: 147613 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 147613 (code=exited, status=0/SUCCESS)
CPU: 810us

Aug 07 17:30:09 FusionPBX systemd[1]: Starting PostgreSQL RDBMS...
Aug 07 17:30:09 FusionPBX systemd[1]: Finished PostgreSQL RDBMS.
root@FusionPBX:/home/pbx2# ● postgresql.service - PostgreSQL RDBMS
bash: ●: command not found
root@FusionPBX:/home/pbx2# Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
bash: syntax error near unexpected token `('
root@FusionPBX:/home/pbx2# Active: active (exited) since Sun 2022-08-07 17:30:09 EDT; 1min 35s ago
bash: syntax error near unexpected token `('
root@FusionPBX:/home/pbx2# Process: 147613 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
bash: syntax error near unexpected token `('
root@FusionPBX:/home/pbx2# Main PID: 147613 (code=exited, status=0/SUCCESS)
bash: syntax error near unexpected token `('
root@FusionPBX:/home/pbx2# CPU: 810us
bash: CPU:: command not found
root@FusionPBX:/home/pbx2# psql -h 127.0.0.1 -U fusionpbx -W -d fusionpbx
Password:
psql: error: connection to server at "127.0.0.1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
root@FusionPBX:/home/pbx2# ss -nltp | grep postgres
root@FusionPBX:/home/pbx2# systemctl status postgresql@13-main.service
postgresql@13-main.service - PostgreSQL Cluster 13-main
Loaded: loaded (/lib/systemd/system/postgresql@.service; enabled-runtime; vendor preset: enabl>
Active: failed (Result: protocol) since Sun 2022-08-07 17:30:09 EDT; 14h ago
Process: 147607 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 13-main start (code=>
CPU: 54ms

Warning: journal has been rotated since unit was started, output may be incomplete.



Verified the pg_hba.conf. Looks the same as your example.


# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
 

hfoster

Active Member
Jan 28, 2019
291
28
28
32
Active: failed (Result: protocol).

This isn't good, you'll need to look back through the journal using 'journalctl' to see where or what caused the process to fail on a restart of the postgres serivce. I wouldn't be surprised if it's to with a PID file.