jonaswinkler / paperless-ng

A supercharged version of paperless: scan, index and archive all your physical documents
https://paperless-ng.readthedocs.io/en/latest/
GNU General Public License v3.0
5.37k stars 356 forks source link

[ERROR] Connection in use: ('localhost', 8000) #227

Closed qcasey closed 3 years ago

qcasey commented 3 years ago

Hello! This evening I updated paperless-ng to 0.9.10 and can't get it to start. The logs below basically repeat forever...

I tried using the provided docker-compose-postgres.yml and .env with the same result.

Did a config change happen somewhere with gunicorn?

webserver_1  | Waiting for PostgreSQL to start...
webserver_1  | Operations to perform:
webserver_1  |   Apply all migrations: admin, auth, authtoken, contenttypes, django_q, documents, paperless_mail, sessions
webserver_1  | Running migrations:
webserver_1  |   No migrations to apply.
webserver_1  | 2020-12-31 02:29:25,253 INFO Set uid to user 0 succeeded
webserver_1  | 2020-12-31 02:29:25,254 INFO supervisord started with pid 1
webserver_1  | 2020-12-31 02:29:26,257 INFO spawned: 'consumer' with pid 29
webserver_1  | 2020-12-31 02:29:26,259 INFO spawned: 'gunicorn' with pid 30
webserver_1  | 2020-12-31 02:29:26,260 INFO spawned: 'scheduler' with pid 31
webserver_1  | [2020-12-31 02:29:26 +0000] [30] [INFO] Starting gunicorn 20.0.4
webserver_1  | [2020-12-31 02:29:26 +0000] [30] [ERROR] Connection in use: ('localhost', 8000)
webserver_1  | [2020-12-31 02:29:26 +0000] [30] [ERROR] Retrying in 1 second.
webserver_1  | 18:29:27 [Q] INFO Q Cluster steak-cola-monkey-pluto starting.
webserver_1  | INFO 2020-12-30 18:29:27,204 document_consumer Using inotify to watch directory for changes: /usr/src/paperless/src/../consume
webserver_1  | 18:29:27 [Q] INFO Process-1:1 ready for work at 49
webserver_1  | 18:29:27 [Q] INFO Process-1:2 ready for work at 50
webserver_1  | 18:29:27 [Q] INFO Process-1:3 ready for work at 51
webserver_1  | 18:29:27 [Q] INFO Process-1:4 monitoring at 52
webserver_1  | 18:29:27 [Q] INFO Process-1 guarding cluster steak-cola-monkey-pluto
webserver_1  | 18:29:27 [Q] INFO Process-1:5 pushing tasks at 53
webserver_1  | 18:29:27 [Q] INFO Q Cluster steak-cola-monkey-pluto running.
webserver_1  | [2020-12-31 02:29:27 +0000] [30] [ERROR] Connection in use: ('localhost', 8000)
webserver_1  | [2020-12-31 02:29:27 +0000] [30] [ERROR] Retrying in 1 second.
webserver_1  | 2020-12-31 02:29:27,390 INFO success: consumer entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
webserver_1  | 2020-12-31 02:29:27,390 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
webserver_1  | 2020-12-31 02:29:27,390 INFO success: scheduler entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
webserver_1  | [2020-12-31 02:29:28 +0000] [30] [ERROR] Connection in use: ('localhost', 8000)
webserver_1  | [2020-12-31 02:29:28 +0000] [30] [ERROR] Retrying in 1 second.
webserver_1  | [2020-12-31 02:29:29 +0000] [30] [ERROR] Connection in use: ('localhost', 8000)
webserver_1  | [2020-12-31 02:29:29 +0000] [30] [ERROR] Retrying in 1 second.
webserver_1  | [2020-12-31 02:29:30 +0000] [30] [ERROR] Connection in use: ('localhost', 8000)
webserver_1  | [2020-12-31 02:29:30 +0000] [30] [ERROR] Retrying in 1 second.
 webserver_1  | [2020-12-31 02:29:31 +0000] [30] [ERROR] Can't connect to ('localhost', 8000)

Thanks for all the releases lately, paperless-ng has been great :smiley:

qcasey commented 3 years ago

Well that was easy enough, I fixed this by removing the 'localhost:8000' from gunicorn.conf.py

https://github.com/jonaswinkler/paperless-ng/blob/3b17f9d6ecc6d1e3459619458ea3fefb260a116d/docker/gunicorn.conf.py#L1

influjensbahr commented 3 years ago

I have the same issue, but can't fix it as easily because I am using the docker image - will this be fixed?

qcasey commented 3 years ago

I'm using the Docker hub image as well. Give this a try if you want it back up ASAP:

sudo docker exec -it paperless-ng_webserver_1 /bin/bash
cd ..
apt update && apt install nano -y
nano gunicorn.conf.py
exit

@jonaswinkler is incredibly responsive, but it's 5AM in Germany right now.

CorneliousJD commented 3 years ago

I have the same issue, but can't fix it as easily because I am using the docker image - will this be fixed?

I just rolled back to jonaswinkler/paperless-ng:0.9.9 for now

influjensbahr commented 3 years ago

Thanks for the tip, @qcasey! I do hope that this error was not caused by my other ticket: https://github.com/jonaswinkler/paperless-ng/issues/185

C0nsultant commented 3 years ago

This is likely caused by #184 and the followup 5c3ae44021c284f93a74cc41857a2dd8fb5710c6. Apparently gunicorn's IPv6 bind ([::]) falls back to IPv4 when IPv6 is not available (as is the case with docker). Having an explicit IPv4 after that might cause this behaviour.

jonaswinkler commented 3 years ago

Well that's just typical. The one time I trust the image to work it doesn't.

Sorry!

growse commented 3 years ago

My bad! Sorry! Should have done some more testing. :(

jonaswinkler commented 3 years ago

The edit that caused this to fail was mine.

However, the gunicorn documentation explicitly states that binding to localhost and [::1] is a valid approach for listening on both IPv4 and IPv6 at the same time. Maybe a bug in gunicorn.

jonaswinkler commented 3 years ago

See also https://github.com/benoitc/gunicorn/issues/1138

influjensbahr commented 3 years ago

Thank you for the quick repair!