502 Bad Gateway nginx

Hello, My box at https://xxx.xxx.xxx/admin is getting a 502 bad gateway error. I can ssh into the box. I can send and receive mail to/from the box. I can open the https://xxx.xxx.xxx/mail and https://xxx.xxx.xxx/cloude websites for the box and log in to my cloud and mail accounts.

I just can’t log into the admin account. I am not sure what to do next.

I have used the below commands to try to clear the issue
sudo mailinabox
sudo reboot
sudo apt-get update && sudo apt-get upgrade
sudo reboot
sudo service mailinabox start
systemctl status mailinabox

root@box:~# systemctl status mailinabox
× mailinabox.service - Mail-in-a-Box System Management Service
Loaded: loaded (/etc/systemd/system/mailinabox.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2025-04-11 02:33:40 PDT; 4min 49s ago
Process: 3030 ExecStart=/usr/local/lib/mailinabox/start (code=exited, status=3)
Main PID: 3030 (code=exited, status=3)
CPU: 485ms

Apr 11 02:33:40 box.xxx.xxx start[3036]: from .app import Flask as Flask
Apr 11 02:33:40 box.xxx.xxx start[3036]: File “/usr/local/lib/python3.10/dist-packages/flask/app.py”, line 30, in
Apr 11 02:33:40 box.xxx.xxx start[3036]: from werkzeug.urls import url_quote
Apr 11 02:33:40 box.xxx.xxx start[3036]: ImportError: cannot import name ‘url_quote’ from ‘werkzeug.urls’ (/usr/local/lib/python3.1>
Apr 11 02:33:40 box.xxx.xxx start[3036]: [2025-04-11 02:33:40 -0700] [3036] [INFO] Worker exiting (pid: 3036)
Apr 11 02:33:40 box.xxx.xxx start[3030]: [2025-04-11 02:33:40 -0700] [3030] [ERROR] Worker (pid:3036) exited with code 3
Apr 11 02:33:40 box.xxx.xxx start[3030]: [2025-04-11 02:33:40 -0700] [3030] [ERROR] Shutting down: Master
Apr 11 02:33:40 box.xxx.xxx start[3030]: [2025-04-11 02:33:40 -0700] [3030] [ERROR] Reason: Worker failed to boot.
Apr 11 02:33:40 box.xxx.xxx systemd[1]: mailinabox.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Apr 11 02:33:40 box.xxx.xxx systemd[1]: mailinabox.service: Failed with result ‘exit-code’.
…skipping…
× mailinabox.service - Mail-in-a-Box System Management Service
Loaded: loaded (/etc/systemd/system/mailinabox.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2025-04-11 02:33:40 PDT; 4min 49s ago
Process: 3030 ExecStart=/usr/local/lib/mailinabox/start (code=exited, status=3)
Main PID: 3030 (code=exited, status=3)
CPU: 485ms

Apr 11 02:33:40 box.xxx.xxx start[3036]: from .app import Flask as Flask
Apr 11 02:33:40 box.xxx.xxx start[3036]: File “/usr/local/lib/python3.10/dist-packages/flask/app.py”, line 30, in
Apr 11 02:33:40 box.xxx.xxx start[3036]: from werkzeug.urls import url_quote
Apr 11 02:33:40 box.xxx.xxx start[3036]: ImportError: cannot import name ‘url_quote’ from ‘werkzeug.urls’ (/usr/local/lib/python3.1>
Apr 11 02:33:40 box.xxx.xxx start[3036]: [2025-04-11 02:33:40 -0700] [3036] [INFO] Worker exiting (pid: 3036)
Apr 11 02:33:40 box.xxx.xxx start[3030]: [2025-04-11 02:33:40 -0700] [3030] [ERROR] Worker (pid:3036) exited with code 3
Apr 11 02:33:40 box.xxx.xxx start[3030]: [2025-04-11 02:33:40 -0700] [3030] [ERROR] Shutting down: Master
Apr 11 02:33:40 box.xxx.xxx start[3030]: [2025-04-11 02:33:40 -0700] [3030] [ERROR] Reason: Worker failed to boot.
Apr 11 02:33:40 box.xxx.xxx systemd[1]: mailinabox.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Apr 11 02:33:40 box.xxx.xxx systemd[1]: mailinabox.service: Failed with result ‘exit-code’.

run
df -h /

Disk space?
Are you running the latest version?

Run

curl -s https://mailinabox.email/setup.sh | sudo -E bash

Are you running You must choose the Ubuntu 22.04 x64

As requested, the information below is provided. Any additional assistance would be greatly appreciated.

Disk space does not seem to be an issue.

root@box:~# df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        25G   13G   12G  52% /
root@box:~#

I am running 22.04 but it has more than 50 updates pending.

Enter passphrase for key '/Users/xxxxxx/.ssh/id_rsa': 
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-136-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Sun Apr 13 03:04:58 PDT 2025

  System load:  0.0                Processes:             138
  Usage of /:   51.1% of 24.05GB   Users logged in:       0
  Memory usage: 40%                IPv4 address for eth0: xxx.xxx.xxx.xxx
  Swap usage:   23%                IPv4 address for eth0: xxx.xxx.xxx.xxx

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

Expanded Security Maintenance for Applications is not enabled.

50 updates can be applied immediately.
8 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

9 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm


Last login: Fri Apr 11 02:26:40 2025 from xxx.xxx.xxx.xxx

I ran the curl command above but it seems to have had problems.

root@box:~# curl -s https://mailinabox.email/setup.sh | sudo -E bash
Updating Mail-in-a-Box to v71a . . .
remote: Enumerating objects: 770, done.
remote: Counting objects: 100% (390/390), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 74 (delta 64), reused 16 (delta 12), pack-reused 0 (from 0)
Unpacking objects: 100% (74/74), 22.38 KiB | 210.00 KiB/s, done.
From https://github.com/mail-in-a-box/mailinabox
 * [new tag]         v71a       -> v71a






┌────────────────────────Mail-in-a-Box Installation──────────────────────────┐
│ Hello and thanks for deploying a Mail-in-a-Box!                            │
│                                                                            │
│ I'm going to ask you a few questions.                                      │
│                                                                            │
│ To change your answers later, just run 'sudo mailinabox' from the command  │
│ line.                                                                      │
│                                                                            │
│ NOTE: You should only install this on a brand new Ubuntu installation 100% │
│ dedicated to Mail-in-a-Box. Mail-in-a-Box will, for example, remove        │
│ apache2.                                                                   │
│                                                                            │
├────────────────────────────────────────────────────────────────────────────┤
│                                 <  OK  >                                   │
└────────────────────────────────────────────────────────────────────────────┘
  







┌─────────────────────────────────Hostname───────────────────────────────────┐
│ This box needs a name, called a 'hostname'. The name will form a part of   │
│ the box's web address.                                                     │
│                                                                            │
│ We recommend that the name be a subdomain of the domain in your email      │
│ address, so we're suggesting xxx.xxx.xxx.xxx.                            │
│                                                                            │
│ You can change it, but we recommend you don't.                             │
│                                                                            │
│ Hostname:                                                                  │
│ ┌────────────────────────────────────────────────────────────────────────┐ │
│ │xxx.xxx.xxx.xxx                                                      │ │
│ └────────────────────────────────────────────────────────────────────────┘ │
├────────────────────────────────────────────────────────────────────────────┤
│                       <  OK  >            <Cancel>                         │
└────────────────────────────────────────────────────────────────────────────┘
  




Primary Hostname: xxx.xxx.xxx.xxx
Public IP Address: xxx.xxx.xxx.xxx
Mail-in-a-Box Version: v71a

Updating system packages...
Installing system packages...
Initializing system random number generator...
Firewall is active and enabled on system startup
Synchronizing state of fail2ban.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable fail2ban

FAILED: apt-get -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew install openssl
-----------------------------------------
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 362594 (apt-get)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
-----------------------------------------
root@box:~# sudo reboot
root@box:~# Connection to xxx.xxx.xxx.xxx closed by remote host.
Connection to xxx.xxx.xxx.xxx closed.

Kill the process:

Use

sudo kill <pid> >>>> 362594

Rerun

curl -s https://mailinabox.email/setup.sh | sudo -E bash

See if the error is gone.

I tried rerunning the curl command and got a different error.

Updating system packages...

Installing system packages...

Initializing system random number generator...

Firewall is active and enabled on system startup

Synchronizing state of fail2ban.service with SysV service script with /lib/systemd/systemd-sysv-install.

Executing: /lib/systemd/systemd-sysv-install enable fail2ban

Installing nsd (DNS server)...

Installing Postfix (SMTP server)...

Installing Dovecot (IMAP server)...

Installing OpenDKIM/OpenDMARC...

Installing SpamAssassin...

Installing Nginx (web server)...

Installing Roundcube (webmail)...

Installing Nextcloud (contacts/calendar)...

Nextcloud is already latest version

Error: stepping, UNIQUE constraint failed: oc_users_external.uid, oc_users_external.backend (19)

Installing Z-Push (Exchange/ActiveSync server)...

Installing Mail-in-a-Box system management daemon...

FAILED: /usr/local/lib/mailinabox/env/bin/pip install --upgrade rtyaml email_validator>=1.0.0 exclusiveprocess flask dnspython python-dateutil expiringdict gunicorn qrcode[pil] pyotp idna>=2.0.0 cryptography==37.0.2 psutil postfix-mta-sts-resolver b2sdk boto3

-----------------------------------------

Requirement already satisfied: rtyaml in /usr/local/lib/python3.10/dist-packages (1.0.0)

Requirement already satisfied: email_validator>=1.0.0 in /usr/local/lib/python3.10/dist-packages (2.2.0)

Requirement already satisfied: exclusiveprocess in /usr/local/lib/python3.10/dist-packages (0.9.4)

Requirement already satisfied: flask in /usr/local/lib/python3.10/dist-packages (2.2.3)

Collecting flask

Using cached flask-3.1.0-py3-none-any.whl.metadata (2.7 kB)

Requirement already satisfied: dnspython in /usr/local/lib/python3.10/dist-packages (2.7.0)

Requirement already satisfied: python-dateutil in /usr/local/lib/python3.10/dist-packages (2.9.0.post0)

Requirement already satisfied: expiringdict in /usr/local/lib/python3.10/dist-packages (1.2.2)

Requirement already satisfied: gunicorn in /usr/local/lib/python3.10/dist-packages (23.0.0)

Requirement already satisfied: pyotp in /usr/local/lib/python3.10/dist-packages (2.9.0)

Requirement already satisfied: idna>=2.0.0 in /usr/local/lib/python3.10/dist-packages (3.10)

Requirement already satisfied: cryptography==37.0.2 in /usr/local/lib/python3.10/dist-packages (37.0.2)

Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (7.0.0)

Requirement already satisfied: postfix-mta-sts-resolver in /usr/local/lib/python3.10/dist-packages (1.3.0)

Collecting postfix-mta-sts-resolver

Using cached postfix_mta_sts_resolver-1.5.0-py3-none-any.whl.metadata (17 kB)

Requirement already satisfied: b2sdk in /usr/local/lib/python3.10/dist-packages (2.8.0)

Requirement already satisfied: boto3 in /usr/local/lib/python3.10/dist-packages (1.37.33)

Requirement already satisfied: qrcode[pil] in /usr/local/lib/python3.10/dist-packages (8.1)

Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.10/dist-packages (from cryptography==37.0.2) (1.15.1)

Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from rtyaml) (5.4.1)

Requirement already satisfied: Werkzeug>=3.1 in /usr/local/lib/python3.10/dist-packages (from flask) (3.1.3)

Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from flask) (3.1.2)

Requirement already satisfied: itsdangerous>=2.2 in /usr/local/lib/python3.10/dist-packages (from flask) (2.2.0)

Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from flask) (8.1.7)

Collecting blinker>=1.9 (from flask)

Using cached blinker-1.9.0-py3-none-any.whl.metadata (1.6 kB)

Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil) (1.16.0)

Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from gunicorn) (21.3)

Requirement already satisfied: pillow>=9.1.0 in /usr/local/lib/python3.10/dist-packages (from qrcode[pil]) (9.5.0)

Requirement already satisfied: aiodns>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from postfix-mta-sts-resolver) (3.0.0)

Requirement already satisfied: aiohttp>=3.4.4 in /usr/local/lib/python3.10/dist-packages (from postfix-mta-sts-resolver) (3.8.4)

Requirement already satisfied: annotated_types>=0.5.0 in /usr/local/lib/python3.10/dist-packages (from b2sdk) (0.7.0)

Requirement already satisfied: logfury<2.0.0,>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from b2sdk) (1.0.1)

Requirement already satisfied: requests<3.0.0,>=2.9.1 in /usr/lib/python3/dist-packages (from b2sdk) (2.25.1)

Requirement already satisfied: typing-extensions>=4.7.1 in /usr/local/lib/python3.10/dist-packages (from b2sdk) (4.8.0)

Requirement already satisfied: botocore<1.38.0,>=1.37.33 in /usr/local/lib/python3.10/dist-packages (from boto3) (1.37.33)

Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from boto3) (1.0.1)

Requirement already satisfied: s3transfer<0.12.0,>=0.11.0 in /usr/local/lib/python3.10/dist-packages (from boto3) (0.11.4)

Requirement already satisfied: pycares>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from aiodns>=1.1.1->postfix-mta-sts-resolver) (4.3.0)

Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (21.2.0)

Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (3.1.0)

Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (6.0.4)

Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (4.0.2)

Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (1.8.2)

Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (1.3.3)

Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (1.3.1)

Requirement already satisfied: urllib3!=2.2.0,<3,>=1.25.4 in /usr/lib/python3/dist-packages (from botocore<1.38.0,>=1.37.33->boto3) (1.26.5)

Requirement already satisfied: pycparser in /usr/local/lib/python3.10/dist-packages (from cffi>=1.12->cryptography==37.0.2) (2.21)

Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.1.2->flask) (2.1.2)

Using cached flask-3.1.0-py3-none-any.whl (102 kB)

Using cached postfix_mta_sts_resolver-1.5.0-py3-none-any.whl (30 kB)

Using cached blinker-1.9.0-py3-none-any.whl (8.5 kB)

Installing collected packages: blinker, flask, postfix-mta-sts-resolver

Attempting uninstall: blinker

Found existing installation: blinker 1.4

error: uninstall-distutils-installed-package

× Cannot uninstall blinker 1.4

╰─> It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

-----------------------------------------

root@box:~#

Please try again but this time not as root.
just

curl -s https://mailinabox.email/setup.sh | sudo -E bash

Run

sudo

when you need super user.

Same result more or less.

Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-136-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Tue Apr 15 04:18:35 PDT 2025

  System load:  0.02               Processes:             147
  Usage of /:   54.2% of 24.05GB   Users logged in:       0
  Memory usage: 53%                IPv4 address for eth0: x.x.x.x
  Swap usage:   22%                IPv4 address for eth0: x.x.x.x

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

Expanded Security Maintenance for Applications is not enabled.

55 updates can be applied immediately.
13 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

9 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm


Last login: Mon Apr 14 01:17:32 2025 from 126.94.131.9
root@box:~# curl -s https://mailinabox.email/setup.sh | sudo -E bash

















                            ┌───────────────────────────Mail-in-a-Box Installation──────────────────────────────┐
                            │ Hello and thanks for deploying a Mail-in-a-Box!                                   │  
                            │                                                                                   │  
                            │ I'm going to ask you a few questions.                                             │  
                            │                                                                                   │  
                            │ To change your answers later, just run 'sudo mailinabox' from the command line.   │  
                            │                                                                                   │  
                            │ NOTE: You should only install this on a brand new Ubuntu installation 100%        │  
                            │ dedicated to Mail-in-a-Box. Mail-in-a-Box will, for example, remove apache2.      │  
                            ├───────────────────────────────────────────────────────────────────────────────────┤  
                            │                                     <  OK  >                                      │  
                            └───────────────────────────────────────────────────────────────────────────────────┘  
                                                                                                                   































                           ┌─────────────────────────────────────Hostname────────────────────────────────────────┐
                           │ This box needs a name, called a 'hostname'. The name will form a part of the box's  │  
                           │ web address.                                                                        │  
                           │                                                                                     │  
                           │ We recommend that the name be a subdomain of the domain in your email address, so   │  
                           │ we're suggesting box.x.x.                                                 │  
                           │                                                                                     │  
                           │ You can change it, but we recommend you don't.                                      │  
                           │                                                                                     │  
                           │ Hostname:                                                                           │  
                           │ ┌─────────────────────────────────────────────────────────────────────────────────┐ │  
                           │ │box.x.x                                                              │ │  
                           │ └─────────────────────────────────────────────────────────────────────────────────┘ │  
                           ├─────────────────────────────────────────────────────────────────────────────────────┤  
                           │                           <  OK  >              <Cancel>                            │  
                           └─────────────────────────────────────────────────────────────────────────────────────┘  
                                                                                                                    















Primary Hostname: box.x.x
Public IP Address: x.x.x.x
Mail-in-a-Box Version: v71a

Updating system packages...
Installing system packages...
Initializing system random number generator...
Firewall is active and enabled on system startup
Synchronizing state of fail2ban.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable fail2ban
Installing nsd (DNS server)...
Installing Postfix (SMTP server)...
Installing Dovecot (IMAP server)...
Installing OpenDKIM/OpenDMARC...
Installing SpamAssassin...
Installing Nginx (web server)...
Installing Roundcube (webmail)...
Installing Nextcloud (contacts/calendar)...
Nextcloud is already latest version
Error: stepping, UNIQUE constraint failed: oc_users_external.uid, oc_users_external.backend (19)
Installing Z-Push (Exchange/ActiveSync server)...
Installing Mail-in-a-Box system management daemon...

FAILED: /usr/local/lib/mailinabox/env/bin/pip install --upgrade rtyaml email_validator>=1.0.0 exclusiveprocess flask dnspython python-dateutil expiringdict gunicorn qrcode[pil] pyotp idna>=2.0.0 cryptography==37.0.2 psutil postfix-mta-sts-resolver b2sdk boto3
-----------------------------------------
Requirement already satisfied: rtyaml in /usr/local/lib/python3.10/dist-packages (1.0.0)
Requirement already satisfied: email_validator>=1.0.0 in /usr/local/lib/python3.10/dist-packages (2.2.0)
Requirement already satisfied: exclusiveprocess in /usr/local/lib/python3.10/dist-packages (0.9.4)
Requirement already satisfied: flask in /usr/local/lib/python3.10/dist-packages (2.2.3)
Collecting flask
  Using cached flask-3.1.0-py3-none-any.whl.metadata (2.7 kB)
Requirement already satisfied: dnspython in /usr/local/lib/python3.10/dist-packages (2.7.0)
Requirement already satisfied: python-dateutil in /usr/local/lib/python3.10/dist-packages (2.9.0.post0)
Requirement already satisfied: expiringdict in /usr/local/lib/python3.10/dist-packages (1.2.2)
Requirement already satisfied: gunicorn in /usr/local/lib/python3.10/dist-packages (23.0.0)
Requirement already satisfied: pyotp in /usr/local/lib/python3.10/dist-packages (2.9.0)
Requirement already satisfied: idna>=2.0.0 in /usr/local/lib/python3.10/dist-packages (3.10)
Requirement already satisfied: cryptography==37.0.2 in /usr/local/lib/python3.10/dist-packages (37.0.2)
Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (7.0.0)
Requirement already satisfied: postfix-mta-sts-resolver in /usr/local/lib/python3.10/dist-packages (1.3.0)
Collecting postfix-mta-sts-resolver
  Using cached postfix_mta_sts_resolver-1.5.0-py3-none-any.whl.metadata (17 kB)
Requirement already satisfied: b2sdk in /usr/local/lib/python3.10/dist-packages (2.8.0)
Requirement already satisfied: boto3 in /usr/local/lib/python3.10/dist-packages (1.37.34)
Requirement already satisfied: qrcode[pil] in /usr/local/lib/python3.10/dist-packages (8.1)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.10/dist-packages (from cryptography==37.0.2) (1.15.1)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from rtyaml) (5.4.1)
Requirement already satisfied: Werkzeug>=3.1 in /usr/local/lib/python3.10/dist-packages (from flask) (3.1.3)
Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from flask) (3.1.2)
Requirement already satisfied: itsdangerous>=2.2 in /usr/local/lib/python3.10/dist-packages (from flask) (2.2.0)
Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from flask) (8.1.7)
Collecting blinker>=1.9 (from flask)
  Using cached blinker-1.9.0-py3-none-any.whl.metadata (1.6 kB)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil) (1.16.0)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from gunicorn) (21.3)
Requirement already satisfied: pillow>=9.1.0 in /usr/local/lib/python3.10/dist-packages (from qrcode[pil]) (9.5.0)
Requirement already satisfied: aiodns>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from postfix-mta-sts-resolver) (3.0.0)
Requirement already satisfied: aiohttp>=3.4.4 in /usr/local/lib/python3.10/dist-packages (from postfix-mta-sts-resolver) (3.8.4)
Requirement already satisfied: annotated_types>=0.5.0 in /usr/local/lib/python3.10/dist-packages (from b2sdk) (0.7.0)
Requirement already satisfied: logfury<2.0.0,>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from b2sdk) (1.0.1)
Requirement already satisfied: requests<3.0.0,>=2.9.1 in /usr/lib/python3/dist-packages (from b2sdk) (2.25.1)
Requirement already satisfied: typing-extensions>=4.7.1 in /usr/local/lib/python3.10/dist-packages (from b2sdk) (4.8.0)
Requirement already satisfied: botocore<1.38.0,>=1.37.34 in /usr/local/lib/python3.10/dist-packages (from boto3) (1.37.34)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from boto3) (1.0.1)
Requirement already satisfied: s3transfer<0.12.0,>=0.11.0 in /usr/local/lib/python3.10/dist-packages (from boto3) (0.11.4)
Requirement already satisfied: pycares>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from aiodns>=1.1.1->postfix-mta-sts-resolver) (4.3.0)
Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (21.2.0)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (3.1.0)
Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (6.0.4)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (4.0.2)
Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (1.8.2)
Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (1.3.3)
Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.4.4->postfix-mta-sts-resolver) (1.3.1)
Requirement already satisfied: urllib3!=2.2.0,<3,>=1.25.4 in /usr/lib/python3/dist-packages (from botocore<1.38.0,>=1.37.34->boto3) (1.26.5)
Requirement already satisfied: pycparser in /usr/local/lib/python3.10/dist-packages (from cffi>=1.12->cryptography==37.0.2) (2.21)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.1.2->flask) (2.1.2)
Using cached flask-3.1.0-py3-none-any.whl (102 kB)
Using cached postfix_mta_sts_resolver-1.5.0-py3-none-any.whl (30 kB)
Using cached blinker-1.9.0-py3-none-any.whl (8.5 kB)
Installing collected packages: blinker, flask, postfix-mta-sts-resolver
  Attempting uninstall: blinker
    Found existing installation: blinker 1.4
error: uninstall-distutils-installed-package

× Cannot uninstall blinker 1.4
╰─> It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
-----------------------------------------
root@box:~# reboot
root@box:~# Connection to x.x.x.x closed by remote host.
Connection to x.x.x.x closed.
daniel@Mac ~ % ssh root@x.x.x.x
Enter passphrase for key '/Users/x/.ssh/id_rsa': 
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-136-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Tue Apr 15 04:18:35 PDT 2025

  System load:  0.02               Processes:             147
  Usage of /:   54.2% of 24.05GB   Users logged in:       0
  Memory usage: 53%                IPv4 address for eth0: x.x.x.x
  Swap usage:   22%                IPv4 address for eth0: x.x.x.x

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

Expanded Security Maintenance for Applications is not enabled.

50 updates can be applied immediately.
8 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

9 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm


Last login: Tue Apr 15 04:18:36 2025 from 126.94.131.9
root@box:~# apt-get update
Hit:1 http://mirrors.digitalocean.com/ubuntu jammy InRelease
Hit:2 http://mirrors.digitalocean.com/ubuntu jammy-updates InRelease
Hit:3 http://mirrors.digitalocean.com/ubuntu jammy-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease                                                                               
Hit:5 http://archive.ubuntu.com/ubuntu jammy InRelease                                                                                         
Hit:6 http://ppa.launchpad.net/duplicity-team/duplicity-release-git/ubuntu jammy InRelease                                                     
Hit:7 https://ppa.launchpadcontent.net/duplicity-team/duplicity-release-git/ubuntu jammy InRelease
Hit:8 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease
Reading package lists... Done
root@box:~# apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  libgd3 php php-bcmath php-curl php-dev php-fpm php-gd php-gmp php-imap php-intl php-ldap php-mbstring php-pspell php-soap php-sqlite3
  php-xml php-zip python3-update-manager ubuntu-advantage-tools update-manager-core
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
root@box:~#

Yoa are still running the commands as root. Its says root@box
Don’t you have and normal user on your box.
To change to a normal user the syntax is
su <username>

Then
sudo apt update
sudo apt upgrade
sudo systemctl reboot

On reboot run the curl command as user.
You also have unupgraded packages.

You are ssh ing as root. Make a normal user. This is not a good idea.