title: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url
body: <p>I am encountering this error, when i try to make a call to a service that is deployed using docker-compose on port 5000 from a django application also deployed using docker-compose on port 8000. I am also using nginx. </p>
  
  <pre><code> ConnectionError at /documents/
   HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: 
   /api/documents (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 
   0x7f976607f290&gt;: Failed to establish a new connection: [Errno 111] Connection refused'))
  </code></pre>
  
  <p>Here's the request object right before the request is made</p>
  
  <pre><code>      kwargs  
    {'data': None,
     'files': {'file': ('XXX',
                        &lt;InMemoryUploadedFile: XXX.pdf (application/pdf)&gt;,
                        'application/pdf',
                        {})},
     'headers': {'Authorization': 'Token token=XXX',
                 'Content-Type': 'application/pdf',
                 'PSPDFKit-API-Version': '2020.1.3'},
     'json': None}
    method  
    'post'
    session 
    &lt;requests.sessions.Session object at 0x7f954da972d0&gt;
    url 
    'http://127.0.0.1:5000/api/documents'
  </code></pre>
  
  <p>Here are the relevant files</p>
  
  <p>docker-compose </p>
  
  <pre><code>version: '3.7'
  
  services:
    web:
      build:
        context: ./www
        dockerfile: Dockerfile.prod
      command: gunicorn app.wsgi:application --bind 0.0.0.0:8000
      volumes:
        - ./www:/usr/src/app
        - static_volume:/home/app/web/staticfiles
        - media_volume:/home/app/web/mediafiles
      expose:
        - 8000
      env_file: env.prod
      depends_on:
        - db
    db:
      image: postgres:12.0-alpine
      volumes:
        - postgres_data:/var/lib/postgresql/data/
      env_file: env.prod
    nginx:
      build: ./nginx
      volumes:
        - static_volume:/home/app/web/staticfiles
        - media_volume:/home/app/web/mediafiles
      ports:
        - 1337:80
      depends_on:
        - web
    pspdfkit:
      image: "pspdfkit/pspdfkit:2020.1"
      environment:
        PGUSER: XXX
        PGPASSWORD: XXX
        PGDATABASE: XXX
        PGHOST: db
        PGPORT: 5432
  
        # Activation key for your PSPDFKit Server installation.
        ACTIVATION_KEY: XXXX
  
        # Secret token used for authenticating API requests.
        API_AUTH_TOKEN: XXXX
  
        # Base key used for deriving secret keys for the purposes of authentication.
        SECRET_KEY_BASE: XXXX
  
        # Public key used for verification of JWTs from web clients. It has to be in the PEM format.
        JWT_PUBLIC_KEY: |
          -----BEGIN PUBLIC KEY-----
          XXXXTYYYYY
          -----END PUBLIC KEY-----
        JWT_ALGORITHM: RS256
  
        # Credentials to access the admin dashboard.
        DASHBOARD_USERNAME: XXX
        DASHBOARD_PASSWORD: YYY
      depends_on:
        - db
      restart: always
      ports:
        - "5000:5000"
      volumes:
        - asset_storage:/srv/asset_storage
  
  volumes:
    postgres_data:
    static_volume:
    media_volume:
    asset_storage:
  </code></pre>
  
  <p>nginx.conf</p>
  
  <pre><code>upstream app {
      server web:8000;
  }
  
  
  server {
      client_max_body_size 20M;
      listen 80;
  
      location / {
          proxy_pass http://app;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $host;
          proxy_redirect off;
      }
  
      location /staticfiles/ {
          alias /home/app/web/staticfiles/;
      }
      location /mediafiles/ {
          alias /home/app/web/mediafiles/;
      }
  
  }
  </code></pre>
  
  <p>Settings.py</p>
  
  <pre><code>  PSPDFKIT_SERVER_HOST = "http://127.0.0.1:5000"
    PSPDFKIT_EXTERNAL_SERVER = "http://127.0.0.1:5000"
  </code></pre>
  
  <p>I've tried changing the url to <code>localhost</code>, <code>0.0.0.0</code>, <code>pspdfkit</code>(from the docker-compose file), and also the public ip of the server, but i end up getting the above error in all cases except when i used the public ip (It couldn't establish connection)</p>
  
  <p>I'm not well versed in nginx, so I might be missing some important configuration step that is causing this issue. Help would be appreciated! </p>