Completely remove Peertube from server?

How do I completely remove Peertube from my server?

Is there a tutorial somewhere I can follow?


I don’t think there is such tutorial yet, then this thread might help.
It depends how you did install it

Based on usual installation documented here :

then to uninstall it, reversing the installation might work

This is a totally unverified uninstall, so just what i would do if i had to :

First step is to stop it :

sudo systemctl disable peertube
sudo systemctl stop peertube

and remove its nginx active configuration link

please keep track of where /etc/nginx/sites-available/peertube links to with :

ls -la /etc/nginx/sites-enabled/peertube

this will be needed later to remove it, it usualy is /etc/nginx/sites-available/peertube

then remove site-enabled active configuration and reload nginx.

sudo rm /etc/nginx/sites-enabled/peertube
sudo systemctl reload nginx

from now your peertube instance is no more published, nodejs process was stopped with systemctl and web access stopped and deactivated from nginx.

check if some nodejs process remains, it would indicate you were perhaps not using systemd.

it remains to remove peertube video storage , peertube postgresql databasde, and i don’t know if there is something to do for redis.

Perhaps you might want to do a backup first, i don’t document it here.

from here you will lose everything.

for postgresql ;

sudo -u postgres dropdb -U peertube peertube_prod

for video storage : if it was changed from /var/www/peertube/storage, then it should be found from configuration in /var/www/peertube/config/production.yaml

then sudo rm -rf on directory indicated as storage.

remove nginx configuration you got previously with the ls -l

remove peertube installation rm -rf /var/www/peertube

and remove peertube user

userdel peertube

This is what i would do, still this process can be buggy, and because any untested process is buggy, this one is buggy.

All packages installed can be used for other process, so it is up to you to find if it is a good idea to remove them.

1 Like

Thanks @plhardy

Would you want to add a section in the documentation website?


When doing so I get this

root@Gauss:~# sudo -u postgres dropdb -U peertube peertube_prod
could not change directory to "/root": Permission denied
dropdb: error: could not connect to database template1: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

It seems you don’t have a postgresql database listening, perhaps was removed or never fully installed ?

to check if a systemd postgres service is running :

sudo systemctl status postgresql
â—Ź postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2021-02-01 09:03:35 CET; 3 weeks 6 days ago
 Main PID: 1466 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   Memory: 0B
   CGroup: /system.slice/postgresql.service

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

if not postgres service is activated, you might want to start it …

sudo systemctl start postgresql

to check if there is a postgres listening process :

sudo netstat -lp | grep postgres
tcp        0      0 localhost:postgresql*               LISTEN      15922/postgres      
tcp6       0      0 localhost:postgresql    [::]:*                  LISTEN      15922/postgres      
unix  2      [ ACC ]     STREAM     LISTENING     9496565  15922/postgres       /var/run/postgresql/.s.PGSQL.5432

to check if there is a postgres process at all :

ps auxw | grep postgres

if postgres is running and listening ;

to fix error for "could not change directory to « /root Â»: Permission denied’ you can use -Hiu instead of -u.

by example to see content of db you can use :

sudo -Hiu postgres psql -U peertube peertube_peertube

a database password will be prompted, it can be found in peertube configuration

actual user and database name for peertube is configurable within /var/www/peertube/production.yaml , suffix is to be added to peertube prefix :

example of production.yaml

# Your database name will be OR "peertube"+database.suffix
  hostname: 'localhost'
  port: 5432
  ssl: false
  suffix: '_peertube'
  username: 'peertube'
  password: 'HereISPostgresqlPasswordForSqlUserpeertube"
    max: 5
root@Gauss:~# sudo systemctl status postgresql
â—Ź postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2021-02-26 07:01:09 UTC; 2 days ago
   Main PID: 8876 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 35959)
     Memory: 0B
     CGroup: /system.slice/postgresql.service

root@Gauss:~# sudo netstat -lp | grep postgres - no response

what gives this:

ps auxw | grep postgres

or some traces in postgres service ? :

journalctl -u postgres

what does a restart ?

sudo systemctl restart postgresql

to go deeper checking /var/run/postgresql directory can give hints.

then checking postgresql configuration in /etc/postgresql sub directories.

if postgres was installed only for peertube it can be fully disinstalled, here it is dependent on system, on debian a dpkg remove --purge postgresql would be very radical…

root 20628 0.0 0.0 9668 660 pts/1 S+ 14:43 0:00 grep --color=auto postgres

it runs and I still get the same error

when I run la (or ls -a) i get this root@Gauss:/var/run/postgresql# la 12-main.pg_stat_tmp .s.PGSQL.5432

is full of configs which should I check?

yes it was

root@Gauss:/etc/postgresql/12/main# dpkg remove --purge postgresql-12
dpkg: error: need an action option

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

I alsop deleted this file

sorry it was not dpkg remove but apt remove :

apt remove --purge postgresql-12

i wonder now if postgresql binary is postgresql in your case since /var/run/postgresqlcontains a unix socket entry 12-main.pg_stat_tmp .s.PGSQL.5432

anyway, full removal of postgresql should be fine since it was installed only for peertube.

so if I reinstall it now it should work as inteded

reinstalling postgresql should be fine. it is possible to run multiple versions of postgresql on same host by using different ports, on one of my install i have version 9 and 11 running; but i don’t think you are in this case.

what can be removed and purge is redis if only used by peertube.

apt remove --purge redis-server

also what do I do when it asks me this?

Removing the PostgreSQL server package will leave existing database clusters intact, i.e. their configuration, data, and log directories will not be removed. On purging the package, the directories can optionally be removed.  │    
    │                                                                                                                                                                                                                                   │    
    │ Remove PostgreSQL directories when package is purged?                                                                                                                                                                             │    

yes removal all, select [Yes]

did this aswell can I re-install now?

This forum topic is about peertube removal, not about install, let’s try to not make it too confusing.

feel free to join irc on freenode.node in #peertube channel ( web acces : ), you will certainly have more interacting support there…

postgresql spans over multiple packages, then removing it fully can be done with :

apt remove --purge postgresql*

and this does not removes postgres posix user.

You perhaps ended on this topic because when following peertube install you didn’t set a password for peertube user and just pushed enter.

extract of production guide ( ) Database

$ sudo -u postgres createuser -P peertube

here you should enter a password for postgresql user peertube, it should be copied in production.yaml file. don’t just hit enter else it will be empty, default production yaml uses peertube here, but it is better you pick a stronger one.

$ sudo -u postgres createdb -O peertube -E UTF8 -T template0 peertube_prod