I’m encountering a persistent issue with PostgreSQL where I repeatedly face the error message:
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?
This issue occurs intermittently and seems to happen after some time of running normally. The only way I’ve been able to resolve it is by manually restarting the PostgreSQL service. However, the problem reoccurs after some time.
I have tried troubleshooting by checking if PostgreSQL is running using the ps aux | grep postgres command, verifying that PostgreSQL is indeed running. Also, I have reviewed the PostgreSQL logs, but I couldn’t find any specific error messages or patterns that might be causing this issue.
I am hoping someone can shed light on what might be causing this issue and provide steps or insights on how to diagnose and fix it more effectively. If there are specific logs or configurations I should be looking at or testing, I would greatly appreciate any guidance.
Has anyone else encountered this issue and successfully resolved it? Your help is highly appreciated.
Thank you in advance!
Here is the postgresql log:
LOG: worker process: logical replication launcher (PID 13195) exited with exit code 1 user@db FATAL: terminating connection due to administrator command LOG: shutting down LOG: database system is shut down LOG: listening on IPv4 address "127.0.0.1", port 5432 LOG: could not bind IPv4 address "10.1.4.26": Cannot assign requested address HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. WARNING: could not create listen socket for "10.1.4.26" LOG: listening on IPv4 address "10.1.4.26", port 5432 LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" LOG: database system was shut down at 2023-08-10 22:35:12 UTC LOG: database system is ready to accept connections [unknown]@[unknown] LOG: incomplete startup packet user@db LOG: could not receive data from client: Connection reset by peer
2
Answers
This usually happens when your system shuts down abruptly, try running
postgres -D /usr/local/var/postgres
, you might get the messagethen run
kill PID
which in this case would bekill 4573
To stop future occurrence of this error, I suggest you always stop the server before shutting down the system.
You’ve been hacked. /tmp/kdevtmpfsi is a crypto mining malware. It is not postgresql, but it is running from your postgres account which is why
ps
shows it.Your server keeps shutting down because whoever hacked you keeps shutting it down.