Peertube - 502 bad gateway after failed upgrade : duplicate entries


I tried to upgrade peertube from 2.3 to 2.4 failed, and pre-upgrade backup restoration failed too, because of a GPG error about yarndpkg repository.

I tried this command : curl -sS | sudo apt-key add -, then restore again, and restoration has worked, but with some warnings like :

2020-10-20 12:19:34,356: WARNING - ERREUR:  n'a pas pu créer l'index unique « actor_preferred_username_server_id »
2020-10-20 12:19:34,357: WARNING - DÉTAIL : La clé ("preferredUsername", "serverId")=(flossome__orthodontics, 378) est dupliquée.

Then I had a 502 bad gateway error when trying to access peertube.
I tried to upgrade, upgrade has worked but I’m still with 502 bad gateway. The problem seems to be about impossibility to create some unique indexes and maybe npm error, now I have no idea how to fix it.


  • Hardware: Old laptop or computer
  • YunoHost version: 4.0.8
  • I have access to my server: Through SSH | through the webadmin | direct access via keyboard / screen
  • Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: yes
    • If yes, please explain: old server that has migrated many versions of yunohost.
  • Using, or trying to install package version/branch: 2.4
  • If upgrading, current package version: 2.3

First upgrade :
Failed restore :
Successful restore, but 502 bad gateway error :
Upgrade :

Linked issue on github :

Uh yeah it definitely looks like some issue about initializing / migrating some database entries ? But I dont have any experise on this app to know how to fix it :<

I tried a fresh install, it works.
And now I found this issue :

The solution proposed is : try to remove the problematic entry in your database:

DELETE FROM "accountVideoRate" WHERE "url" = '' LIMIT 1;

I imagine that it’s a command to launch on peertube database ? What could be the complete command on yunohost ?

I tried to remove duplicate entries using adminer, but i’m blocked with an error for some entries : "ERREUR: UPDATE ou DELETE sur la table “videoChannel” viole la contrainte de clé étrangère.
And I don’t know how many duplicater entries there are.

Ok, I finally managed to get peertube back working. Using adminer, I’ve deleted all remote videos, all remote actors, and all tags.
I think the database is not clean, but it’s working…

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.