Ufw.service is not loaded properly: Exec format error

Hi there,

I have 2 systems running Virtualmin. I use one as a Test server and another one as Prod.

On the Test server, under Webmin -> Boot and Shutdown, I have 2 UFW entries: ufw and ufw.service

However, on Prod, I had only 1 entry: UFW

Whenever Test Server reboots, UFW is automatically on, but this is not the case for Prod. So I thought I will write my own system services and created one called ufw.service, I copied the entry from the Test Server. I had a feeling that the details for the service were wrong, but nevertheless, I clicked OK. And it just disappeared. It did not give me any warning, error or success/failure message.

Just so you know, this is what I entered in “Commands to run on startup”

[Unit]
Description=Uncomplicated firewall
Documentation=man:ufw(8)
DefaultDependencies=no
Before=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/lib/ufw/ufw-init start quiet
ExecStop=/lib/ufw/ufw-init stop

[Install]
WantedBy=multi-user.target

I then went back to restart UFW service and since then I am getting an error message saying:

“Starting ufw (via systemctl): ufw.serviceFailed to start ufw.service: Unit ufw.service is not loaded properly: Exec format error.
See system logs and ‘systemctl status ufw.service’ for details.
failed!”

This is happening when I try to start the service Now or on Boot – via Webmin.

However, the good news is I rebooted the server and the UFW status was inactive but I was able to enable ufw without any issue.

I know what mistake I have done; I also know what entry I have made and I want to delete/undo that changes. But I don’t know where is that file saved for me to go there and revert the changes.

I am worried this will create a bigger issue for me sooner or later.

I tried looking for help on the internet and there are few posts but none of them is conclusive and there is nothing on the Virtualmin forum, so I am raising a new/fresh issue.

Can someone please let me know how do I correct this mistake and then we can discuss how to enable ufw to be enabled on boot.

Many Thanks,
Rav

Near the bottom left corner of the Webmin / Virtualmin interface is an icon which looks like >_, captioned terminal. Click on the icon and you will see a black screen with cursor. At the cursor, type or paste

systemctl status ufw.service

and hit Enter. You will see an error report, if the firewall service has failed. Try google or paste it here for us to be able to offer suggestions.

Hi rav, I would agree with @calport or perhaps contact ufw developer regards this issue…

Thanks for the help.

I think I have managed to fix it… the file was written at: /lib/systemd/system/ufw.service
and the exact same file was also available at: /etc/systemd/system/multi-user.target.wants/ufw.service not sure if they have been symlinked…

The formatting as well as few details were wrong. Corrected them, restarted ufw few time times, rebooted machine and everything seems to be working fine at least as of now.

However, I am now facing another issue w.r.t unable to login to roundcube and getting error message:

504 Gateway Time-out

The server didn’t respond in time.

I am not sure if this new error is related to this ufw issue that I had, so I have opened a new case here - assuming they are 2 different issue with 2 different root cause.

Would appreciate if you can pls have a look and help me out as it is the production server that is taking the hit.

Many Thanks,
Rav

I think I have managed to resolve the issue with 504 as well (at least for the time being.) Details have been updated in the main thread.

Thx: Rav

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.