We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't start inventree server
It seems that error at `https://api.exchangerate.host/latest` blocks server startup.

```
# curl https://api.exchangerate.host/latest
<html>
<head><title>521 Origin Down</title></head>
<body bgcolor="white">
<center><h1>521 Origin Down</h1></center>
<hr><center>cloudflare-nginx</center>
</body>
</html>
```

<details>

```
# inv server
InvenTree Database Configuration
================================
ENGINE: django.db.backends.mysql
NAME: inventree
HOST: localhost
Base currency changed from USD to RUB
Updating exchange rates from https://api.exchangerate.host/latest
Using base currency 'RUB'
InvenTree Database Configuration
================================
ENGINE: django.db.backends.mysql
NAME: inventree
HOST: localhost
Base currency changed from USD to RUB
Updating exchange rates from https://api.exchangerate.host/latest
Using base currency 'RUB'
Watching for file changes with StatReloader
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    autoreload.check_errors(django.setup)()
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/var/projects/inventree/inventree/InvenTree/InvenTree/apps.py", line 24, in ready
    self.update_exchange_rates()
  File "/var/projects/inventree/inventree/InvenTree/InvenTree/apps.py", line 105, in update_exchange_rates
    update_exchange_rates()
  File "/var/projects/inventree/inventree/InvenTree/InvenTree/tasks.py", line 199, in update_exchange_rates
    backend.update_rates(base_currency=base)
  File "/var/projects/inventree/inventree/InvenTree/InvenTree/exchange.py", line 29, in update_rates
    super().update_rates(base=base_currency, symbols=symbols)
  File "/usr/lib64/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/djmoney/contrib/exchange/backends/base.py", line 68, in update_rates
    for currency, value in self.get_rates(**params).items()
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/djmoney/contrib/exchange/backends/base.py", line 80, in get_rates
    response = self.get_response(**params)
  File "/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/djmoney/contrib/exchange/backends/base.py", line 48, in get_response
    response = urlopen(url, cafile=certifi.where())
  File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib64/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 521: Origin Down
```

</details>

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `InvenTree/InvenTree/exchange.py`
Content:
```
1 from common.settings import currency_code_default, currency_codes
2 
3 from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend
4 
5 
6 class InvenTreeExchange(SimpleExchangeBackend):
7     """
8     Backend for automatically updating currency exchange rates.
9 
10     Uses the exchangerate.host service API
11     """
12 
13     name = "InvenTreeExchange"
14 
15     def __init__(self):
16         self.url = "https://api.exchangerate.host/latest"
17 
18         super().__init__()
19 
20     def get_params(self):
21         # No API key is required
22         return {
23         }
24 
25     def update_rates(self, base_currency=currency_code_default()):
26 
27         symbols = ','.join(currency_codes())
28 
29         super().update_rates(base=base_currency, symbols=symbols)
30
```
--- 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()

```

diff --git a/InvenTree/InvenTree/exchange.py b/InvenTree/InvenTree/exchange.py
--- a/InvenTree/InvenTree/exchange.py
+++ b/InvenTree/InvenTree/exchange.py
@@ -1,4 +1,5 @@
 from common.settings import currency_code_default, currency_codes
+from urllib.error import HTTPError, URLError
 
 from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend
 
@@ -26,4 +27,8 @@
 
         symbols = ','.join(currency_codes())
 
-        super().update_rates(base=base_currency, symbols=symbols)
+        try:
+            super().update_rates(base=base_currency, symbols=symbols)
+        # catch connection errors
+        except (HTTPError, URLError):
+            print('Encountered connection error while updating')

{"golden_diff": "diff --git a/InvenTree/InvenTree/exchange.py b/InvenTree/InvenTree/exchange.py\n--- a/InvenTree/InvenTree/exchange.py\n+++ b/InvenTree/InvenTree/exchange.py\n@@ -1,4 +1,5 @@\n from common.settings import currency_code_default, currency_codes\n+from urllib.error import HTTPError, URLError\n \n from djmoney.contrib.exchange.backends.base import SimpleExchangeBackend\n \n@@ -26,4 +27,8 @@\n \n         symbols = ','.join(currency_codes())\n \n-        super().update_rates(base=base_currency, symbols=symbols)\n+        try:\n+            super().update_rates(base=base_currency, symbols=symbols)\n+        # catch connection errors\n+        except (HTTPError, URLError):\n+            print('Encountered connection error while updating')\n", "issue": "Can't start inventree server\nIt seems that error at `https://api.exchangerate.host/latest` blocks server startup.\r\n\r\n```\r\n# curl https://api.exchangerate.host/latest\r\n<html>\r\n<head><title>521 Origin Down</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>521 Origin Down</h1></center>\r\n<hr><center>cloudflare-nginx</center>\r\n</body>\r\n</html>\r\n```\r\n\r\n<details>\r\n\r\n```\r\n# inv server\r\nInvenTree Database Configuration\r\n================================\r\nENGINE: django.db.backends.mysql\r\nNAME: inventree\r\nHOST: localhost\r\nBase currency changed from USD to RUB\r\nUpdating exchange rates from https://api.exchangerate.host/latest\r\nUsing base currency 'RUB'\r\nInvenTree Database Configuration\r\n================================\r\nENGINE: django.db.backends.mysql\r\nNAME: inventree\r\nHOST: localhost\r\nBase currency changed from USD to RUB\r\nUpdating exchange rates from https://api.exchangerate.host/latest\r\nUsing base currency 'RUB'\r\nWatching for file changes with StatReloader\r\nWatching for file changes with StatReloader\r\nException in thread django-main-thread:\r\nTraceback (most recent call last):\r\n  File \"/usr/lib64/python3.6/threading.py\", line 916, in _bootstrap_inner\r\n    self.run()\r\n  File \"/usr/lib64/python3.6/threading.py\", line 864, in run\r\n    self._target(*self._args, **self._kwargs)\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/utils/autoreload.py\", line 64, in wrapper\r\n    fn(*args, **kwargs)\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/core/management/commands/runserver.py\", line 110, in inner_run\r\n    autoreload.raise_last_exception()\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/utils/autoreload.py\", line 87, in raise_last_exception\r\n    raise _exception[1]\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/core/management/__init__.py\", line 375, in execute\r\n    autoreload.check_errors(django.setup)()\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/utils/autoreload.py\", line 64, in wrapper\r\n    fn(*args, **kwargs)\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/__init__.py\", line 24, in setup\r\n    apps.populate(settings.INSTALLED_APPS)\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/django/apps/registry.py\", line 122, in populate\r\n    app_config.ready()\r\n  File \"/var/projects/inventree/inventree/InvenTree/InvenTree/apps.py\", line 24, in ready\r\n    self.update_exchange_rates()\r\n  File \"/var/projects/inventree/inventree/InvenTree/InvenTree/apps.py\", line 105, in update_exchange_rates\r\n    update_exchange_rates()\r\n  File \"/var/projects/inventree/inventree/InvenTree/InvenTree/tasks.py\", line 199, in update_exchange_rates\r\n    backend.update_rates(base_currency=base)\r\n  File \"/var/projects/inventree/inventree/InvenTree/InvenTree/exchange.py\", line 29, in update_rates\r\n    super().update_rates(base=base_currency, symbols=symbols)\r\n  File \"/usr/lib64/python3.6/contextlib.py\", line 52, in inner\r\n    return func(*args, **kwds)\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/djmoney/contrib/exchange/backends/base.py\", line 68, in update_rates\r\n    for currency, value in self.get_rates(**params).items()\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/djmoney/contrib/exchange/backends/base.py\", line 80, in get_rates\r\n    response = self.get_response(**params)\r\n  File \"/var/projects/inventree/inventree-env/lib64/python3.6/site-packages/djmoney/contrib/exchange/backends/base.py\", line 48, in get_response\r\n    response = urlopen(url, cafile=certifi.where())\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 223, in urlopen\r\n    return opener.open(url, data, timeout)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 532, in open\r\n    response = meth(req, response)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 642, in http_response\r\n    'http', request, response, code, msg, hdrs)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 570, in error\r\n    return self._call_chain(*args)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 504, in _call_chain\r\n    result = func(*args)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 650, in http_error_default\r\n    raise HTTPError(req.full_url, code, msg, hdrs, fp)\r\nurllib.error.HTTPError: HTTP Error 521: Origin Down\r\n```\r\n\r\n</details>\n", "before_files": [{"content": "from common.settings import currency_code_default, currency_codes\n\nfrom djmoney.contrib.exchange.backends.base import SimpleExchangeBackend\n\n\nclass InvenTreeExchange(SimpleExchangeBackend):\n    \"\"\"\n    Backend for automatically updating currency exchange rates.\n\n    Uses the exchangerate.host service API\n    \"\"\"\n\n    name = \"InvenTreeExchange\"\n\n    def __init__(self):\n        self.url = \"https://api.exchangerate.host/latest\"\n\n        super().__init__()\n\n    def get_params(self):\n        # No API key is required\n        return {\n        }\n\n    def update_rates(self, base_currency=currency_code_default()):\n\n        symbols = ','.join(currency_codes())\n\n        super().update_rates(base=base_currency, symbols=symbols)\n", "path": "InvenTree/InvenTree/exchange.py"}], "after_files": [{"content": "from common.settings import currency_code_default, currency_codes\nfrom urllib.error import HTTPError, URLError\n\nfrom djmoney.contrib.exchange.backends.base import SimpleExchangeBackend\n\n\nclass InvenTreeExchange(SimpleExchangeBackend):\n    \"\"\"\n    Backend for automatically updating currency exchange rates.\n\n    Uses the exchangerate.host service API\n    \"\"\"\n\n    name = \"InvenTreeExchange\"\n\n    def __init__(self):\n        self.url = \"https://api.exchangerate.host/latest\"\n\n        super().__init__()\n\n    def get_params(self):\n        # No API key is required\n        return {\n        }\n\n    def update_rates(self, base_currency=currency_code_default()):\n\n        symbols = ','.join(currency_codes())\n\n        try:\n            super().update_rates(base=base_currency, symbols=symbols)\n        # catch connection errors\n        except (HTTPError, URLError):\n            print('Encountered connection error while updating')\n", "path": "InvenTree/InvenTree/exchange.py"}]}