If you search for this question on the internet, you will get a lot of answers telling you, that this is impossible. But there is a way to do it and it is not too complicated:

Let's say you are on Ubuntu 23.04 Lunar Lobster and you want to upgrade to the next supported version, currently 24.04. To accomplish this without risking too many stability issues, you have to go through the also outdated version 23.10. Here is how it's done:

  1. Take a backup of everything you don't want to lose! You probably won't need it, but it never hurts.
  2. Create a backup of the file /etc/apt/sources.list.
  3. Edit /etc/apt/sources.list and repace the "archive" or "[country].archive" part of all urls (in this case "gb.archive") with "old-releases" and the name of the Ubuntu version (in this case "noble") with the name of the next release after the currently installed one. It is important, that you don't skip a release here, so for 23.04 Lunar Lobster it has to be 23.10 Mantic Minotaur!
    # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    # newer versions of the distribution.
    deb http://gb.archive.ubuntu.com/ubuntu lunar main restricted
    
    ## Major bug fix updates produced after the final release of the
    ## distribution.
    deb http://gb.archive.ubuntu.com/ubuntu lunar-updates main restricted
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    ## team. Also, please note that software in universe WILL NOT receive any
    ## review or updates from the Ubuntu security team.
    deb http://gb.archive.ubuntu.com/ubuntu lunar universe
    deb http://gb.archive.ubuntu.com/ubuntu lunar-updates universe
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
    ## team, and may not be under a free licence. Please satisfy yourself as to 
    ## your rights to use the software. Also, please note that software in 
    ## multiverse WILL NOT receive any review or updates from the Ubuntu
    ## security team.
    deb http://gb.archive.ubuntu.com/ubuntu lunar multiverse
    deb http://gb.archive.ubuntu.com/ubuntu lunar-updates multiverse
    
    ## N.B. software from this repository may not have been tested as
    ## extensively as that contained in the main release, although it includes
    ## newer versions of some applications which may provide useful features.
    ## Also, please note that software in backports WILL NOT receive any review
    ## or updates from the Ubuntu security team.
    deb http://gb.archive.ubuntu.com/ubuntu lunar-backports main restricted universe multiverse
    
    deb http://gb.archive.ubuntu.com/ubuntu lunar-security main restricted
    deb http://gb.archive.ubuntu.com/ubuntu lunar-security universe
    deb http://gb.archive.ubuntu.com/ubuntu lunar-security multiverse
    The result should look like this:
    # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    # newer versions of the distribution.
    deb http://old-releases.ubuntu.com/ubuntu mantic main restricted
    
    ## Major bug fix updates produced after the final release of the
    ## distribution.
    deb http://old-releases.ubuntu.com/ubuntu mantic-updates main restricted
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    ## team. Also, please note that software in universe WILL NOT receive any
    ## review or updates from the Ubuntu security team.
    deb http://old-releases.ubuntu.com/ubuntu mantic universe
    deb http://old-releases.ubuntu.com/ubuntu mantic-updates universe
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
    ## team, and may not be under a free licence. Please satisfy yourself as to 
    ## your rights to use the software. Also, please note that software in 
    ## multiverse WILL NOT receive any review or updates from the Ubuntu
    ## security team.
    deb http://old-releases.ubuntu.com/ubuntu mantic multiverse
    deb http://old-releases.ubuntu.com/ubuntu mantic-updates multiverse
    
    ## N.B. software from this repository may not have been tested as
    ## extensively as that contained in the main release, although it includes
    ## newer versions of some applications which may provide useful features.
    ## Also, please note that software in backports WILL NOT receive any review
    ## or updates from the Ubuntu security team.
    deb http://old-releases.ubuntu.com/ubuntu mantic-backports main restricted universe multiverse
    
    deb http://old-releases.ubuntu.com/ubuntu mantic-security main restricted
    deb http://old-releases.ubuntu.com/ubuntu mantic-security universe
    deb http://old-releases.ubuntu.com/ubuntu mantic-security multiverse
  4.  open a console and execute the folowing commands:
    sudo apt-get update
    followed by:
    sudo apt-get dist-upgrade
    This will upgrade all installed packages to the release in your sources.list file. Grab a tea or coffee and wait until it's done. It might ask you, if you want to update or keep altered configuration files.

  5. When the last step is finished, enter the following command to get rid of old packages, that are no longer needed:
    apt-get autoremove
  6. Finally execute the following command (probably not necessary, just to be on the safe side):
    sudo update-grub
  7. Reboot the system
    You should now be on the Ubuntu version you've set in sources.list.
  8. If you have installed 3rd party apps, look into /etc/apt/sources.list.d and update all .list files there to reflect the current release, in our example "mantic".
  9. Perform a software update with the following commands or using the Ubuntu software updater:
    sudo apt update
    followed by:
    sudo apt-upgrade
  10. Update all snap packages
    sudo snap refresh
  11. If you have Flatpak packages installed, update them as well:
    flatpak update
  12. Reboot the system
  13. If you are still not on a supported Ubuntu release, repeat steps 2. - 12. until you are on a supported version.
  14. Once you are on a supported version again, change back all occurrences of "old-releases" in /etc/apt/sources.list to "archive".

At this point you should be able to use the Ubuntu system updater to do any further upgrades.