0

On Kubuntu 20.04

Before I can successfully start a docker container on my computer I need to kill a Postgres process. I do this by:

  1. sudo ss -lptn 'sport = :5432'

,which outputs: State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 244 127.0.0.1:5432 0.0.0.0:* users:(("postgres",pid=1003,fd=5))

  1. kill <pid>

Now I would be able to run the docker container that has a Postgres database. I'd like it so that I don't have to follow those steps before I can run any Postgres database. For some reason lsof -i :5432 does not return the process.

Is it standard behaviour for Postgres to be running in the background? Is it safe to stop this process? If yes, how can I stop this process from running automatically in the background?

I have tried the following commands with no success:
sudo systemctl disable postgresql
sudo update-rc.d postgresql disable

1
  • If the Postgres process is associated PostgreSQL then this article may help you. fatdragon.me/blog/2016/05/… If you don't have PostgreSQL installed, then you need to 1. find out what the process is and what it does. Then decide if you need it running or not. Commented Nov 8, 2021 at 22:18

1 Answer 1

0

Killing a database process is a really good way of destroying a database. PostgreSQL is not installed by default so something or someone must have put it on the machine for a reason. You will want to confirm if anything on your system needs it.

To answer the question, though, you can safely stop PostgreSQL like this:

sudo service postgresql stop 

You can prevent PostgreSQL from starting at boot like this:

sudo service postgresql disable 

If nothing on your system needs the database engine to be installed locally, you can remove it:

sudo apt --purge remove postgresql 

Note: This removes just the server element, leaving the client libraries intact to connect to PostgreSQL installations.

3
  • thanks for your comment but sudo service postgresql disable doesn't do anything. It returns sudo service postgresql disable Commented Nov 9, 2021 at 9:29
  • Have also tried sudo systemctl disable postgresql, but that didn't fix it Commented Nov 9, 2021 at 9:32
  • and tried sudo update-rc.d postgresql disable Commented Nov 9, 2021 at 10:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.