Connect to host application from a container at a specific port

I am running an application on host machine on port XYZ.

I was running a docker container and from the container, I need to connect to the application on the host machine on port XYZ

One way which I found out was to restart the container with the following flag

1
--add-host host.docker.internal:host-gateway

With this addition, you can refer to the application on the host machine from inside the container by going to host.docker.internal:XYZ