Error "Database initialization failed" / "Unable to connect to the database"

This error usually occurs the first time you start the app, but can occur upon subsequent starts.

If there is something you don’t understand, feel free to reply on this topic.

If this is the first time you’ve started the application

Something prevents the database system from starting with the app :

Windows

  • If your username contains an accent character like é à è, etc. you’ll need to install a Karaoke Mugen portable version. Karaoke Mugen doesn’t support accent characters in its path. To do so :
    • First uninstall the app
    • Remove the C:\Users\myusername\KaraokeMugen folder
    • Download a portable version from the Download page
    • Unzip it in a folder of your choice, like C:\KaraokeMugen, or on an external drive.
    • You can start the app from its folder.

Linux

PostgreSQL needs to be configured and launched prior to Karaoke Mugen’s launch when y ou use our Debian/Ubuntu packages. For more information, see this section from the documentation

If it worked before

There may be a problem with your database. We advise you reach to us on Discord with your log file ready.

But if you’re in a hurry and your database doesn’t contain anything valuable like custom playlists you spent hours on or stats you didn’t send to us via the stats upload prompt, you can safely erase the database and create a new one.

To do that :

  • Go to KM’s data directory:
    • Windows: c:\users\myuser\karaokemugen
    • Linux & Mac: ~/KaraokeMugen
  • Go into the db directory
  • Rename the postgresql directory to something else, like postgres.old
  • Restart Karaoke Mugen, this will trigger a new database initialization.

@AxelTerizaki dead link for the docs, new page is Installation :: Karaoke Mugen Documentation

I fixed that, thank you :slight_smile:

Hey AxelTerizaki, I have just joined the community about 2 hours ago, I’ve been trying to fix my issue of “Error connecting to database” by reinstalling KaraokeMugen (8.0.22) using the stable version, using the portable version, and using a newer version that was released today (8.0.37). Each version I have used for KaraokeMugen, it would give me the same error. And I am able to ping kara.moe. Would you happen to know any other ways to fix my issue?

Hello and thank you for using KM, and posting here for support!

I can’t really help without log files though. You’ll find the KM log in c:\users\your_user\appdata\roaming\karaokemugen-app\app\logs if I’m not mistaken. You can send them to me on Discord in DMs or here.

1 « J'aime »

Solved, the VC++ redistribuable wasn’t installed.

To install it : https://aka.ms/vs/17/release/vc_redist.x64.exe

I am having this issue with both portable and installer versions, and it seems to be identical on my laptop and my desktop. Both are running Windows 11, FWIW; the log from my most recent attempt to uninstall and reinstall is attached. I tried installing the above redistributable, but no luck. Appreciate the help.
karaokemugen-2025-02-19.log (27.0 KB)

Hello :slight_smile:

First, thanks for checking the forum, searching for a similar topic and posting logs :smiley:

I’m not quite sure where the problem is if you installed the redistribuable, it should work™

If you’re familiar with the terminal/commandline, can you try to go inside the postgres folder and run postgres.exe without any arguments ? It should be located here judging from your logs :C:\\Users\\ironw\\AppData\\Local\\Programs\\Karaoke Mugen\\app\\bin\\postgres\\bin\\

If that executable displays something in the terminal, I’m not sure yet what causes it not to work on Karaoke Mugen. If it displays a pop up window with an error message, I’d love to hear about it :slight_smile:

When I try to run postgres.exe, the terminal only pops up for a fraction of a second (not enough time for me to even see what is there) then closes.

Sorry I wasn’t precise enough. I meant :

  • Open a terminal
  • Go to the folder I mentionned
  • Try to launch postgres.exe

But seeing as ti doesn’t display any dialog box, it means it’s using the redistribuable you downloaded and installed.

We can try to create the database by hand to try to see where it’s crashing. You can open a terimnal, go in the folder, and launch the following command :

pg_ctl.exe init -o "-U postgres -E UTF8" -D "C:\Users\ironw\AppData\Roaming\karaokemugen-app\app\db\postgres"

Please post the result here so we can try to find out what’s wrong :slight_smile: