It is probably a firewall issue. Try to disable firewalld for just a minute. If that works, enable it again and try to fix the configuration. I rmemember that when I was on Centos, I had to configure firewalld. Without that my containers could not communicate with each other. But I don’t remember the exact configuration.
An other example for Ubuntu Docker Compose network: cannot use default docker gateway to connect to host machine from container, unless a custom network is manually specified - #5 by swissknight