PMG 9.0.2 – “Not a HASH reference at PMG/API2/Transport.pm line 51” after adding relay/transport via pmgsh

Nolfik

New Member
Jun 16, 2025
10
0
1
Hello
I have a reproducible issue on a single-node Proxmox Mail Gateway 9.0.2 installation running on Debian 13 (Trixie). When relay domains and transport mappings are added through the GUI, everything works fine. However, when the same entries are added using pmgsh, the PMG Web GUI stops displaying them correctly.

After adding domains or transports via CLI:
  • The “Relay Domains” tab in the GUI becomes completely empty (no domains are shown).
  • The “Transports” tab fails to load and shows “Connection error”.
  • The API endpoint /api2/extjs/config/transport returns HTTP 500:
    Code:
    Not a HASH reference at /usr/share/perl5/PMG/API2/Transport.pm line 51.
  • Postfix continues to deliver mail normally, so the issue affects only the GUI/API layer.
  • CLI shows valid data:
    Code:
    pmgsh get /config/domains
    pmgsh get /config/transport
    Both return JSON and “200 OK”.
  • Removing /etc/pmg/domains and /etc/pmg/transport does not resolve the issue — the GUI and API functionality are restored only after reinstall, and the problem reappears as soon as a new domain is added through the CLI.
 
When relay domains and transport mappings are added through the GUI, everything works fine. However, when the same entries are added using pmgsh, the PMG Web GUI stops displaying them correctly.
As the GUI and pmgsh use the same code-paths in the backend this sounds odd or might point to a quoting issue - which entries do you try to add/create
(please anonymize what you don't want to have public - but keep it consistent (if your replace proxmox.com with xxx.domain then do so everywhere with xxx.domain)

* how do /etc/pmg/domain and /etc/pmg/transport look like before you add your entries
* how do /etc/pmg/domain and /etc/pmg/transport look like after you add your entries

Removing /etc/pmg/domains and /etc/pmg/transport does not resolve the issue — the GUI and API functionality are restored only after reinstall, and the problem reappears as soon as a new domain is added through the CLI.
removing the files is not correct - if you want to reset them - just create an empty file - postfix also needs those files (or rather the generated db-files to run, and the db-files are regenerated by PMG at a few places)
 
@Stoiko Ivanov
Thank you for responding to my problem.
Before I started adding relay and transport, the files were empty of course

Code:
cat /etc/pmg/domains
test1.com 1
test2.com 1

Code:
cat /etc/pmg/transport
test1.com smtp:[*.*.*.239]:25
test2.com smtp:[*.*.*.239]:25

test1.com added manually via GUI
test2.com added via pmgsh

here are the commands I used to do it
Code:
pmgsh create /config/transport \
--domain test2.com \
--host *.*.*.239 \
--port 25 \
--protocol smtp \
--use_mx 0

Code:
pmgsh create /config/domains --domain test2.com


I reinstalled the server on Debian 12 and installed version 8.2.6
and applied the same playbook and everything works ok. I don't understand what the problem is
 

Attachments

  • Screenshot 2025-11-11 at 17.45.30.png
    Screenshot 2025-11-11 at 17.45.30.png
    68.1 KB · Views: 3
  • Screenshot 2025-11-11 at 17.46.01.png
    Screenshot 2025-11-11 at 17.46.01.png
    108 KB · Views: 3
  • Screenshot 2025-11-11 at 17.45.54.png
    Screenshot 2025-11-11 at 17.45.54.png
    75.7 KB · Views: 3
Last edited:
here are the commands I used to do it
ran that command with an rfc1918 IP (192.168.244.244) and it worked and did not break the GUI - so maybe the issue might be ansible (or python3) related?
does the issue also occur if you run the command without playbook?

the journal might contain some messages explaining why it's not working
 
I can reproduce the issue even without Ansible. I used real public IPs in production (I only posted obfuscated/fake IPs in the thread). The problem occurs both when I run the pmgsh commands manually over SSH and when the same commands are executed by Ansible. Fresh single-node PMG 9.0.2 (Debian 13/Trixie). GUI works as expected until I add the first relay domain via pmgsh; immediately after that the “Relay Domains” tab becomes empty and the “Transports” tab shows “Connection error”. The ExtJS API returns 500 with “Not a HASH reference at /usr/share/perl5/PMG/API2/Transport.pm line 51”.

It is not limited to public IPs; I can also reproduce with an RFC1918 host (e.g., 192.168.244.244). Removing /etc/pmg/domain and /etc/pmg/transport does not fix it; on my systems the GUI/API only recover after a full reinstall. The same playbook and the same pmgsh commands work fine on PMG 8.2.6 (Debian 11) — GUI shows Relay Domains and Transports normally there — so this looks like a regression/change in PMG 9.


Unfortunately, there are no errors in the logs — everything looks normal.
 
For the sake of experiment, I set up a new server manually, without Ansible — same result: as soon as I run the command, the GUI breaks.
 
Removing /etc/pmg/domain and /etc/pmg/transport does not fix it;
Yes - as said above - when you remove the files this is to be expected! - do not remove them, but truncate them (make them an empty file)

until I add the first relay domain via pmgsh; immediately after that the “Relay Domains” tab becomes empty and the “Transports” tab shows “Connection error”.
how exactly do the two files look afterwards? - as said I cannot reproduce the problem when running your pmgsh command from above

you could also install etckeeper before running the command and then check `cd /etc; git diff` after running it - in case the command modifies something else in the config directory
 
  1. Reinstalled the server completely.
  2. Installed PMG manually using apt install proxmox-mailgateway.
  3. Everything works fine, no crashes.
  4. The /etc/pmg/domains and /etc/pmg/transport files were empty initially.
  5. Added the domain test1.com manually via GUI for both relay and transport — everything worked as expected.
  6. Then I executed this command manually:
  7. Code:
    pmgsh create /config/domains --domain test2.com
  8. After that, the Relay Domains section in the GUI became empty, although Transport still worked and showed no errors.
  9. Next, I ran:
    Code:
    pmgsh create /config/transport --domain test2.com --host 192.168.244.244 --port 25 --protocol smtp
  10. After this, the Transport tab in the GUI started showing a connection error (URL - 500).

The attached screenshots show the etckeeper diff and the contents of /etc/pmg/domains and /etc/pmg/transport after running the commands.
 

Attachments

  • Screenshot 2025-11-12 at 14.45.34.png
    Screenshot 2025-11-12 at 14.45.34.png
    165.3 KB · Views: 2
  • Screenshot 2025-11-12 at 14.47.52.png
    Screenshot 2025-11-12 at 14.47.52.png
    30.2 KB · Views: 2
  • Screenshot 2025-11-12 at 14.52.12.png
    Screenshot 2025-11-12 at 14.52.12.png
    76.6 KB · Views: 2
  • Screenshot 2025-11-12 at 14.53.15.png
    Screenshot 2025-11-12 at 14.53.15.png
    161.3 KB · Views: 2
  • Screenshot 2025-11-12 at 14.53.38.png
    Screenshot 2025-11-12 at 14.53.38.png
    40.2 KB · Views: 2