/dev/ttyS1: Permission denied on centos 9

Getting the permission denied error on writing data to /dev/ttyS* serial port. It works on centos 8.
Even tried adding the username to the dialout group.
sudo usermod -a $(name) -G dialout
Please suggest.

@Welcome.

I believe you need to log out for group membership to take effect.

You should also post (copy/paste) command and errors rather than verbalising what has happened - ie : 'it doesn't work' or 'I get permission denied' are way less informative than the actual command and its supporting messages EG:

echo 'hello' > /dev/ttyS1
bash: /dev/ttyS1: Permission denied

Additionally, learn to use markdown when posting code - use the menu options at the top of the dialog box when you type.
tks

Please show the result of

ls -ld /dev/ttyS*
id -a
echo 'data' > /dev/ttyS1
bash: /dev/ttyS1: Permission denied

$ ls -ld /dev/ttyS*
crw--w----. 1 root root 136, 0 Aug 11 20:24 /dev/ttyS0
crw--w----. 1 root root 136, 1 Aug 11 20:24 /dev/ttyS1
crw--w----. 1 root root 136, 2 Aug 11 20:24 /dev/ttyS2

$ id -a
uid=1000(username1) gid=1000(username1) groups=1000(username1),100000(network-admin),5(tty),10(wheel),18(username1)

Two groups with the same name?
1000(username1)
18(username1)
Can lead to confusion. On Fedora-like systems GID 1000 belongs to groupname users. So consider renaming it back.

The device is writeable(-only) by group 0(root), so consider adding username1 to group root
either by

sudo usermod -aG root username1

or by

sudo gpasswd -a root username1

Removed username1 from 18 (dialout group).

$id -a
uid=1000(username1) gid=1000(username1) groups=1000(username1),100000(network-admin),5(tty),10(wheel)

$ sudo gpasswd -a root username1
Adding user root to group username1

$ echo 'data' > /dev/ttyS1
bash: /dev/ttyS1: Permission denied

Thanks for the info @ativader09. It is likely the root cause.
So in CentOS 8 the devices were owned by group dialout. This is not the case here. Perhaps a bug in CentOS 9?

I still don't get why GID 18 was named username1 not dialout. A mistake in /etc/group?

I guess this is not what you want. Vice versa:

$ sudo gpasswd -a username1 root

Ah yes, that's the correct argument order for gpasswd. I gave the wrong order.
And the group "username1" should not exist at all, perhaps it is the GID 18 and should be renamed "dialout".

at least in Debian, dialout group id is 20, so that is quite likely.