Score:0

Can I stop postgres running in the background?

gd flag

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

Score:0
in flag

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.

Ambassador Kosh avatar
gd flag
thanks for your comment but `sudo service postgresql disable` doesn't do anything. It returns `sudo service postgresql disable`
Ambassador Kosh avatar
gd flag
Have also tried `sudo systemctl disable postgresql`, but that didn't fix it
Ambassador Kosh avatar
gd flag
and tried `sudo update-rc.d postgresql disable`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.