Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)SU
Posts
2
Comments
1
Joined
2 yr. ago
Docker @lemmy.world
sunwoo1524 @lemmy.world

Connection to server at "127.0.0.1", port 5432 failed: Connection refused

FastAPI container fails to connect to PostgreSQL.
However, the PostgreSQL container is running well and accessible.
I don't know why this problem is happening.
Here is gist link of Dockerfile, docker-compose.yaml and log when docker-compose is run. https://gist.github.com/sunwoo1524/9f75b4d3fd295c9829705e23a3b8094d

Python @programming.dev
sunwoo1524 @lemmy.world

ImportError: attempted relative import with no known parent package

I ran Python, FastAPI, and PostgreSQL as docker-compose, but it doesn't work with these errors.
I don't know why this error occurs.
Full Error Message:

 undefined
    
learn-fastapi-web-1  | Traceback (most recent call last):
learn-fastapi-web-1  |   File "<frozen runpy>", line 198, in _run_module_as_main
learn-fastapi-web-1  |   File "<frozen runpy>", line 88, in _run_code
learn-fastapi-web-1  |   File "/usr/local/lib/python3.11/site-packages/uvicorn/__main__.py", line 4, in <module>
learn-fastapi-web-1  |     uvicorn.main()
learn-fastapi-web-1  |   File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
learn-fastapi-web-1  |     return self.main(*args, **kwargs)
learn-fastapi-web-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
learn-fastapi-web-1  |   File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
learn-fastapi-web-1  |     rv = self.invoke(ctx)
learn-fastapi-web-1  |          ^^^^^^^^^^^^^^^^
learn-fastapi-web-1  |   File "/usr/lo