full-stack-fastapi-template
full-stack-fastapi-template copied to clipboard
Unable to reload backend with start-reload.sh script due to '[Errno 98] Address already in use' error
Hi everyone,
I'm developing services on the backend side and struggling to reload it in order to take into account my changes with the /start-reload.sh script:
root@f9f21e5f6088:/app# bash /start-reload.sh
Checking for script in /app/prestart.sh
Running script /app/prestart.sh
INFO:__main__:Initializing service
INFO:__main__:Starting call to '__main__.init', this is the 1st time calling it.
INFO:__main__:Service finished initializing
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO:__main__:Creating initial data
INFO:__main__:Initial data created
ERROR: [Errno 98] Address already in use
Thinking it could be an issue with an old container not visible but still running in the background I removed all images and containers and rebuilt everything but I'm still having the issue unfortunately. Any idea of how I could solve this? Thanks a lot!!
[Errno 98] Address already in use
I guess it's a port has occupied, you can use kill command to close. e.g.
kill -9 `lsof -t -i:port`
if not, ignore my answer. :)
you can also comment out alembic https://github.com/tiangolo/full-stack-fastapi-postgresql/blob/490c554e23343eec0736b06e59b2108fdd057fdc/%7B%7Bcookiecutter.project_slug%7D%7D/backend/app/prestart.sh#L7
Thanks for your replies @CoderCharm and @haviduck!
About the first the first solution, unfortunately it seems that lsof is not installed by default on the docker container, did you have to install it manually one the container?:
MacBook-Pro-de-Jerome:verva jeromeceyrac$ docker-compose exec backend bash
WARNING: The following deploy sub-keys are not supported and have been ignored: labels
WARNING: The following deploy sub-keys are not supported and have been ignored: labels
WARNING: The following deploy sub-keys are not supported and have been ignored: labels
WARNING: The following deploy sub-keys are not supported and have been ignored: labels
WARNING: The following deploy sub-keys are not supported and have been ignored: labels
root@c560f43d0b7f:/app# lsof
bash: lsof: command not found
root@c560f43d0b7f:/app#
I'll try to install it manually...
Commenting alembic doesn't seem to solve the issue unfortunately (I've commented the line in pre_start.py and restared the backend container).
Is it a normal behaviour that the address is in use by default since because I haven't changed any of the default configuration...
Ok, I've installed lsof, so I guess now I need to find out which process and port the reload pre_start.sh script is using and are occupied? The lsof command is returning quite a lot of stuff :(
root@c560f43d0b7f:/app# lsof
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
uvicorn 1 root cwd DIR 0,80 608 39804987 /app
uvicorn 1 root rtd DIR 0,161 4096 2491045 /
uvicorn 1 root txt REG 0,161 36864 1183601 /usr/local/bin/python3.7
uvicorn 1 root mem REG 254,1 1183601 /usr/local/bin/python3.7 (path dev=0,161)
uvicorn 1 root mem REG 254,1 131672 /lib/x86_64-linux-gnu/liblzma.so.5.2.4 (path dev=0,161)
...
Same error here, does anyone any idea?
I had the same problem, to solve this you should comment line 54 in docker-compose.override.yml and uncomment line 53.
It should looks like this:
command: bash -c "while true; do sleep 1; done"
# command: /start-reload.sh
After that everything works perfect.
Hi! I don't know if this has already been solved but as any of these methods worked for me because my "flower" service was failing since the beginning. Once I solved it, it was working great! The solution was to modify the docker-compose.yml file and mher/flower adding tag like this:
mher/flower:0.9.4
Hi! I don't know if this has already been solved but as any of these methods worked for me because my "flower" service was failing since the beginning. Once I solved it, it was working great! The solution was to modify the docker-compose.yml file and
mher/floweradding tag like this:mher/flower:0.9.4
yeah :)
https://github.com/tiangolo/full-stack-fastapi-postgresql/issues/294#issuecomment-708839262
Having this issue as well. Port is in use.
I've tried everything, and yet I still have the issue, has anyone found another solution?
Hi, it might be a very stupid question but I cannot find the "start-reload.sh" anywhere. Where is it located? or was it removed?
I had the same problem, to solve this you should comment line 54 in
docker-compose.override.ymland uncomment line 53. It should looks like this:command: bash -c "while true; do sleep 1; done" # command: /start-reload.shAfter that everything works perfect.
Thanks a lot. I spent hours to find out what's wrong until I find your fix. I think this project really needs some love from the maintainer (@tiangolo). I wasted many hours make it work fine (struggled with flower too)