FastAPI + Postgresql in Docker

I have an urgent trouble in docker usage
I have made two containers for postgresql and fastapi backend.
I can connect postgresql container on my localhost but I cant connect there from fastapi container
When I request to my fastapi backend, it gets data from postgresql container but not connect there now
Please help me with the solution