prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [BUG] Error starting gunicorn when IPv6 is disabled on host
  ### Description
  
  Paperless fails to launch in at least certain scenarios when IPv6 is disabled on the host. This was working before a change from listening on `0.0.0.0` to listening on `::`.
  
  ### Steps to reproduce
  
  Add the following to `/etc/sysctl.conf`:
  
  ```
  net.ipv6.conf.all.disable_ipv6=1
  net.ipv6.conf.default.disable_ipv6=1
  net.ipv6.conf.lo.disable_ipv6=1
  ```
  
  Set `GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"` in `/etc/default/grub`, and `update-grub`.
  
  Reboot and run paperless-ngx
  
  ### Webserver logs
  
  ```bash
  Paperless-ngx docker container starting...
  Mapping UID and GID for paperless:paperless to 1000:65538
  usermod: no changes
  Creating directory /tmp/paperless
  Adjusting permissions of paperless files. This may take a while.
  Waiting for PostgreSQL to start...
  Waiting for Redis: redis://paperless-redis.paperless.svc:6379
  Connected to Redis broker: redis://paperless-redis.paperless.svc:6379
  Apply database migrations...
  Operations to perform:
    Apply all migrations: admin, auth, authtoken, contenttypes, django_q, documents, paperless_mail, sessions
  Running migrations:
    No migrations to apply.
  Executing /usr/local/bin/paperless_cmd.sh
  2022-08-04 14:20:24,984 INFO Set uid to user 0 succeeded
  2022-08-04 14:20:24,985 INFO supervisord started with pid 49
  2022-08-04 14:20:25,988 INFO spawned: 'consumer' with pid 50
  2022-08-04 14:20:25,990 INFO spawned: 'gunicorn' with pid 51
  2022-08-04 14:20:25,992 INFO spawned: 'scheduler' with pid 52
  [2022-08-04 10:20:26 -0400] [51] [INFO] Starting gunicorn 20.1.0
  [2022-08-04 10:20:35 -0400] [72] [ERROR] Retrying in 1 second.
  [2022-08-04 10:20:36 -0400] [72] [ERROR] Retrying in 1 second.
  [2022-08-04 10:20:37 -0400] [72] [ERROR] Can't connect to ('::', 8000)
  2022-08-04 14:20:37,727 INFO exited: gunicorn (exit status 1; not expected)
  2022-08-04 14:20:38,730 INFO spawned: 'gunicorn' with pid 74
  [2022-08-04 10:20:39 -0400] [74] [INFO] Starting gunicorn 20.1.0
  [2022-08-04 10:20:39 -0400] [74] [ERROR] Retrying in 1 second.
  2022-08-04 14:20:40,017 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  [2022-08-04 10:20:40 -0400] [74] [ERROR] Retrying in 1 second.
  [2022-08-04 10:20:41 -0400] [74] [ERROR] Retrying in 1 second.
  [2022-08-04 10:20:42 -0400] [74] [ERROR] Retrying in 1 second.
  [2022-08-04 10:20:43 -0400] [74] [ERROR] Retrying in 1 second.
  [2022-08-04 10:20:44 -0400] [74] [ERROR] Can't connect to ('::', 8000)
  2022-08-04 14:20:44,069 INFO exited: gunicorn (exit status 1; not expected)
  ```
  
  
  ### Paperless-ngx version
  
  1.8.0
  
  ### Host OS
  
  Ubuntu 22.04 x64, Microk8s 1.22
  
  ### Installation method
  
  Docker - official image
  
  ### Browser
  
  _No response_
  
  ### Configuration changes
  
  _No response_
  
  ### Other
  
  This seems to be a regression from https://github.com/paperless-ngx/paperless-ngx/pull/924. Changing the listen IP back to 0.0.0.0 in gunicorn.conf.py causing it to bind correctly again
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `gunicorn.conf.py`
  Content:
  ```
  1 import os
  2 
  3 bind = f'[::]:{os.getenv("PAPERLESS_PORT", 8000)}'
  4 workers = int(os.getenv("PAPERLESS_WEBSERVER_WORKERS", 1))
  5 worker_class = "paperless.workers.ConfigurableWorker"
  6 timeout = 120
  7 
  8 
  9 def pre_fork(server, worker):
  10     pass
  11 
  12 
  13 def pre_exec(server):
  14     server.log.info("Forked child, re-executing.")
  15 
  16 
  17 def when_ready(server):
  18     server.log.info("Server is ready. Spawning workers")
  19 
  20 
  21 def worker_int(worker):
  22     worker.log.info("worker received INT or QUIT signal")
  23 
  24     ## get traceback info
  25     import threading, sys, traceback
  26 
  27     id2name = {th.ident: th.name for th in threading.enumerate()}
  28     code = []
  29     for threadId, stack in sys._current_frames().items():
  30         code.append("\n# Thread: %s(%d)" % (id2name.get(threadId, ""), threadId))
  31         for filename, lineno, name, line in traceback.extract_stack(stack):
  32             code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
  33             if line:
  34                 code.append("  %s" % (line.strip()))
  35     worker.log.debug("\n".join(code))
  36 
  37 
  38 def worker_abort(worker):
  39     worker.log.info("worker received SIGABRT signal")
  40
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/gunicorn.conf.py b/gunicorn.conf.py
  --- a/gunicorn.conf.py
  +++ b/gunicorn.conf.py
  @@ -1,6 +1,6 @@
   import os
   
  -bind = f'[::]:{os.getenv("PAPERLESS_PORT", 8000)}'
  +bind = f'{os.getenv("PAPERLESS_BIND_ADDR", "[::]")}:{os.getenv("PAPERLESS_PORT", 8000)}'
   workers = int(os.getenv("PAPERLESS_WEBSERVER_WORKERS", 1))
   worker_class = "paperless.workers.ConfigurableWorker"
   timeout = 120
  
verification_info: {"golden_diff": "diff --git a/gunicorn.conf.py b/gunicorn.conf.py\n--- a/gunicorn.conf.py\n+++ b/gunicorn.conf.py\n@@ -1,6 +1,6 @@\n import os\n \n-bind = f'[::]:{os.getenv(\"PAPERLESS_PORT\", 8000)}'\n+bind = f'{os.getenv(\"PAPERLESS_BIND_ADDR\", \"[::]\")}:{os.getenv(\"PAPERLESS_PORT\", 8000)}'\n workers = int(os.getenv(\"PAPERLESS_WEBSERVER_WORKERS\", 1))\n worker_class = \"paperless.workers.ConfigurableWorker\"\n timeout = 120\n", "issue": "[BUG] Error starting gunicorn when IPv6 is disabled on host\n### Description\n\nPaperless fails to launch in at least certain scenarios when IPv6 is disabled on the host. This was working before a change from listening on `0.0.0.0` to listening on `::`.\n\n### Steps to reproduce\n\nAdd the following to `/etc/sysctl.conf`:\r\n\r\n```\r\nnet.ipv6.conf.all.disable_ipv6=1\r\nnet.ipv6.conf.default.disable_ipv6=1\r\nnet.ipv6.conf.lo.disable_ipv6=1\r\n```\r\n\r\nSet `GRUB_CMDLINE_LINUX_DEFAULT=\"ipv6.disable=1\"` in `/etc/default/grub`, and `update-grub`.\r\n\r\nReboot and run paperless-ngx\n\n### Webserver logs\n\n```bash\nPaperless-ngx docker container starting...\r\nMapping UID and GID for paperless:paperless to 1000:65538\r\nusermod: no changes\r\nCreating directory /tmp/paperless\r\nAdjusting permissions of paperless files. This may take a while.\r\nWaiting for PostgreSQL to start...\r\nWaiting for Redis: redis://paperless-redis.paperless.svc:6379\r\nConnected to Redis broker: redis://paperless-redis.paperless.svc:6379\r\nApply database migrations...\r\nOperations to perform:\r\n  Apply all migrations: admin, auth, authtoken, contenttypes, django_q, documents, paperless_mail, sessions\r\nRunning migrations:\r\n  No migrations to apply.\r\nExecuting /usr/local/bin/paperless_cmd.sh\r\n2022-08-04 14:20:24,984 INFO Set uid to user 0 succeeded\r\n2022-08-04 14:20:24,985 INFO supervisord started with pid 49\r\n2022-08-04 14:20:25,988 INFO spawned: 'consumer' with pid 50\r\n2022-08-04 14:20:25,990 INFO spawned: 'gunicorn' with pid 51\r\n2022-08-04 14:20:25,992 INFO spawned: 'scheduler' with pid 52\r\n[2022-08-04 10:20:26 -0400] [51] [INFO] Starting gunicorn 20.1.0\r\n[2022-08-04 10:20:35 -0400] [72] [ERROR] Retrying in 1 second.\r\n[2022-08-04 10:20:36 -0400] [72] [ERROR] Retrying in 1 second.\r\n[2022-08-04 10:20:37 -0400] [72] [ERROR] Can't connect to ('::', 8000)\r\n2022-08-04 14:20:37,727 INFO exited: gunicorn (exit status 1; not expected)\r\n2022-08-04 14:20:38,730 INFO spawned: 'gunicorn' with pid 74\r\n[2022-08-04 10:20:39 -0400] [74] [INFO] Starting gunicorn 20.1.0\r\n[2022-08-04 10:20:39 -0400] [74] [ERROR] Retrying in 1 second.\r\n2022-08-04 14:20:40,017 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)\r\n[2022-08-04 10:20:40 -0400] [74] [ERROR] Retrying in 1 second.\r\n[2022-08-04 10:20:41 -0400] [74] [ERROR] Retrying in 1 second.\r\n[2022-08-04 10:20:42 -0400] [74] [ERROR] Retrying in 1 second.\r\n[2022-08-04 10:20:43 -0400] [74] [ERROR] Retrying in 1 second.\r\n[2022-08-04 10:20:44 -0400] [74] [ERROR] Can't connect to ('::', 8000)\r\n2022-08-04 14:20:44,069 INFO exited: gunicorn (exit status 1; not expected)\n```\n\n\n### Paperless-ngx version\n\n1.8.0\n\n### Host OS\n\nUbuntu 22.04 x64, Microk8s 1.22\n\n### Installation method\n\nDocker - official image\n\n### Browser\n\n_No response_\n\n### Configuration changes\n\n_No response_\n\n### Other\n\nThis seems to be a regression from https://github.com/paperless-ngx/paperless-ngx/pull/924. Changing the listen IP back to 0.0.0.0 in gunicorn.conf.py causing it to bind correctly again\n", "before_files": [{"content": "import os\n\nbind = f'[::]:{os.getenv(\"PAPERLESS_PORT\", 8000)}'\nworkers = int(os.getenv(\"PAPERLESS_WEBSERVER_WORKERS\", 1))\nworker_class = \"paperless.workers.ConfigurableWorker\"\ntimeout = 120\n\n\ndef pre_fork(server, worker):\n    pass\n\n\ndef pre_exec(server):\n    server.log.info(\"Forked child, re-executing.\")\n\n\ndef when_ready(server):\n    server.log.info(\"Server is ready. Spawning workers\")\n\n\ndef worker_int(worker):\n    worker.log.info(\"worker received INT or QUIT signal\")\n\n    ## get traceback info\n    import threading, sys, traceback\n\n    id2name = {th.ident: th.name for th in threading.enumerate()}\n    code = []\n    for threadId, stack in sys._current_frames().items():\n        code.append(\"\\n# Thread: %s(%d)\" % (id2name.get(threadId, \"\"), threadId))\n        for filename, lineno, name, line in traceback.extract_stack(stack):\n            code.append('File: \"%s\", line %d, in %s' % (filename, lineno, name))\n            if line:\n                code.append(\"  %s\" % (line.strip()))\n    worker.log.debug(\"\\n\".join(code))\n\n\ndef worker_abort(worker):\n    worker.log.info(\"worker received SIGABRT signal\")\n", "path": "gunicorn.conf.py"}], "after_files": [{"content": "import os\n\nbind = f'{os.getenv(\"PAPERLESS_BIND_ADDR\", \"[::]\")}:{os.getenv(\"PAPERLESS_PORT\", 8000)}'\nworkers = int(os.getenv(\"PAPERLESS_WEBSERVER_WORKERS\", 1))\nworker_class = \"paperless.workers.ConfigurableWorker\"\ntimeout = 120\n\n\ndef pre_fork(server, worker):\n    pass\n\n\ndef pre_exec(server):\n    server.log.info(\"Forked child, re-executing.\")\n\n\ndef when_ready(server):\n    server.log.info(\"Server is ready. Spawning workers\")\n\n\ndef worker_int(worker):\n    worker.log.info(\"worker received INT or QUIT signal\")\n\n    ## get traceback info\n    import threading, sys, traceback\n\n    id2name = {th.ident: th.name for th in threading.enumerate()}\n    code = []\n    for threadId, stack in sys._current_frames().items():\n        code.append(\"\\n# Thread: %s(%d)\" % (id2name.get(threadId, \"\"), threadId))\n        for filename, lineno, name, line in traceback.extract_stack(stack):\n            code.append('File: \"%s\", line %d, in %s' % (filename, lineno, name))\n            if line:\n                code.append(\"  %s\" % (line.strip()))\n    worker.log.debug(\"\\n\".join(code))\n\n\ndef worker_abort(worker):\n    worker.log.info(\"worker received SIGABRT signal\")\n", "path": "gunicorn.conf.py"}]}