Script updating from v4.5.19

Hi guys,
I’ve been running v4.5.19 for a while now and never really updated it as it was working fine. This was around the time v5 was also out and required totally separate installation. So today, I thought let’s try to use the script to update instead.

However, there are two things.

  1. I notice that the script is attempting to update directly to v5.10.8
  2. The connection is timing out

[root@shahz public_html]# sudo /home/user/public_html/update_ninja.sh

Tue Feb 25 22:41:39 PST 2025 - Updating Invoice Ninja from v4.5.19 to v5.10.8.

Deleting file “/home/user/public_html/bootstrap/cache/compiled.php” (if it exists)…

rm: cannot remove ‘/home/user/public_html/bootstrap/cache/compiled.php’: No such file or directory

Downloading Invoice Ninja v5.10.8 archive “https://download.invoiceninja.com/ninja-v5.10.8.zip” …

–2025-02-25 22:41:39-- https://download.invoiceninja.com/ninja-v5.10.8.zip

Resolving download.invoiceninja.com (download.invoiceninja.com)… 198.74.58.235

Connecting to download.invoiceninja.com (download.invoiceninja.com)|198.74.58.235|:443… failed: Connection timed out.

Retrying.

–2025-02-25 22:43:47-- (try: 2) https://download.invoiceninja.com/ninja-v5.10.8.zip

Connecting to download.invoiceninja.com (download.invoiceninja.com)|198.74.58.235|:443… failed: Connection timed out.

Retrying.

–2025-02-25 22:45:56-- (try: 3) https://download.invoiceninja.com/ninja-v5.10.8.zip

Connecting to download.invoiceninja.com (download.invoiceninja.com)|198.74.58.235|:443…

I suppose the URL that its downloading from https://download.invoiceninja.com/ninja-v5.10.8.zip which is inaccessible. I suppose this can be downloaded from https://github.com/invoiceninja/invoiceninja/archive/refs/tags/v5.10.8.zip instead and I can edit the script, but this would break things right?

Hi,

You’ll need to first update to 4.5.50. You may want to setup a clean v4 install, copy over your database and .env file and then try to migrate.

Thanks for the response @hillel

I believe v4.5.50 uses PHP7.4 now right? I’ve been running 4.5.19 with PHP7.3
I do have both of them installed, just need confirmation as I see a lot of mixed comments in the forums.

Yes, that is correct

Hey @hillel,

I am setting up a fresh installation of 4.5.50 and there’s a little problem.

I managed to get to the setup page, filled up all the information including the database credentials. All the tests were successful, and upon continuing, I get Error 500

When I try to run
sudo -u user /opt/cpanel/ea-php74/root/usr/bin/php /home/user/public_html/artisan migrate --force

I get this error:

In Connection.php line 669:
                                                                                                                                                                                                               
  SQLSTATE[HY000] [1045] Access denied for user 'dbuser'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = dbname and table_name =  
   migrations and table_type = 'BASE TABLE')                                                                                                                                                                   
                                                                                                                                                                                                               

In PDOConnection.php line 47:
                                                                                                       
  SQLSTATE[HY000] [1045] Access denied for user 'dbuser'@'localhost' (using password: YES)  
                                                                                                       

In PDOConnection.php line 43:
                                                                                                       
  SQLSTATE[HY000] [1045] Access denied for user 'dbuser'@'localhost' (using password: YES)

** Private credentials have been altered for security reasons. I am able to connect to the database via the user and password and it has all the permissions granted, so I’m not sure what is going on.

I have also tried changing the DB_HOST=127.0.0.1 instead of localhost and then ran:

sudo -u user /opt/cpanel/ea-php74/root/usr/bin/php /home/user/public_html/artisan config:clear
sudo -u user /opt/cpanel/ea-php74/root/usr/bin/php /home/userpublic_html/artisan cache:clear

and tried running migration again, still no dice.

Any idea what’s going on?

I’m not sure why you’re seeing that error, but you’ll want to set up the v4 install using a copy of your existing v4 database using mysqldump.

So you recommend I restore the database over the new installation? I was under the impression I get a fresh copy running, and then only overwrite the database.

I’ll try to overwrite the database for now with the mysqldump of the 4.5.19 and see if that fixes it

Note: from the error, it looks like the database user in the .env file doesn’t have permission to access the database.

It may help to run php artisan config:clear

Hey @hillel Since things were getting really broken, I restored everything back to 4.5.19 again.
So what I’m doing now is just overwrite the existing files with the ones from 4.5.50 and then go into the UI, settings → Account Management and hit Migration. I select self hosted, add the URL and credentials and upon hitting submit, nothing really happens. It still stays at 4.5.19. What am I missing here? Is there any way to troubleshoot this?

The migration requires v4.5.50 to run. I think you’re better off setting up a new install so you don’t break your current one.

If I setup a new install altogether, will I be able to still bring my data (clients, invoices, payment records, etc) over to the new version though? Maybe by exporting or something?

If you setup the new install with a copy of the existing v4 database it will have all of the data.

Hmm… that is what I was doing earlier but it didnt really install properly… I’ll try it again, this time with a totally clean slate since the backups are still working fine when I restore them…

One more question, to move to v5 later on, will I need a new domain? Or will I be able to use the existing domain still? I remember the last time it required a totally new domain and install for setting up v5

You can have v4 and v5 running on the same domain, you could use different subdomains or paths.

Oh! This is new. I believe I’ve seen this many times in the docs that invoice ninja only runs on primary domain and cannot run on subdomains. Okay, I’ll try doing a clean slate v4.5.50 install once again and see if this works.

Can you share a link to where you’re seeing this?

Hi @hillel Its totally my bad… Its supposed to be installed in “root directory” of the domain/subdomain… I misread that… I’m so sorry about that…

Hi @hillel

So, after countless attempts of upgrading and constant fails, I have finally given up. I just cant upgrade the 4.5.19 to 4.5.50 no matter how I try it. So, for now, I’m just going to continue using this version and maybe eventually just start fresh on v5 from scratch.

However, since I have migrated to a new host, there’s a new issue that’s rising. For some reasons, it cant connect to my mailserver, throwing the following error:

Connection could not be established with host mail.jerungmail.com [Connection timed out #110]

I use the exact same credentials on Outlook and it works perfectly fine. What could be the problem here?
I’m able to ping to my mailserver from the server where its hosted. I enabled debug and this is what it shows:

[15:27:24] LOG.error: Connection could not be established with host mail.jerungmail.com [Connection timed out #110]
 {"context":"PHP","user_id":1,"account_id":1,"user_name":"M******* A****","method":"POST","user_agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/133.0.0.0 Safari\/537.36","locale":"en","ip":"xxx.xxx.xxx.xxx","count":8,"is_console":"no","is_api":"no","db_server":"mysql","url":"setup"}

Sensitive information has been redacted. Any help is appreciated. Everything else seems to be working fine, only the mailserver is not connecting.

You may want to try using telnet to confirm the host/port are reachable from the server.

@hillel It seems to be reachable from SSH…

[u@host public_html]$ curl -v telnet://mail.jerungmail.com:465
*   Trying 2400:8901::xxxx:xxxx:xxxx:xxxx:465...
*   Trying xxx.xxx.xxx.xxx:465...
* Connected to mail.jerungmail.com (xxx.xxx.xxx.xxx) port 465 (#0)
^C
[u@host public_html]$ curl -v telnet://mail.jerungmail.com:587
*   Trying 2400:8901::xxxx:xxxx:xxxx:xxxx:587...
*   Trying xxx.xxx.xxx.xxx:587...
* Connected to mail.jerungmail.com (xxx.xxx.xxx.xxx) port 587 (#0)
220 mail.jerungmail.com ESMTP Postcow