question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Call to dcim.devices.all() fails with a 504 when using nginx and uwsgi

See original GitHub issue

Environment

  • Python version: 3.8.11
  • Nautobot version: 1.2.3
  • nginx version: 1:1.16-1-1.el7.ngx
  • uwsgi version: 2.0.19.1

Steps to Reproduce

  1. Deploy nautobot with nginx and uwsgi
  2. Import a number of devices into nautobot
  3. Call dcim.devices.all (either through restapi or pynautobot)

Expected Behaviour

All devices should be returned via the api Note: this worked against demo.nautobot.com (~300 devices), local install has ~5200 devices

Observed Behaviour

504 gateway timeout from the server

client log:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/demo/Library/Python/3.8/lib/python/site-packages/pynautobot/core/endpoint.py", line 99, in all
    return response_loader(req.get(), self.return_obj, self)
  File "/Users/demo/Library/Python/3.8/lib/python/site-packages/pynautobot/core/query.py", line 295, in get
    return req_all()
  File "/Users/demo/Library/Python/3.8/lib/python/site-packages/pynautobot/core/query.py", line 253, in req_all
    req = self._make_call(add_params=add_params)
  File "/Users/demo/Library/Python/3.8/lib/python/site-packages/pynautobot/core/query.py", line 226, in _make_call
    raise RequestError(req)
pynautobot.core.query.RequestError: The request failed with code 504 Gateway Time-out but more specific details were not returned in json. Check the Nautobot Logs or investigate this exception's error attribute.

uwsgi log:

Thu Feb  3 11:35:17 2022 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET /api/dcim/devices/ (192.0.2.55)
OSError: write error

nginx log:

2022/02/03 11:34:56 [error] 28892#28892: *35577 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.0.2.55, server: nautobot-dev-1.example.com, request: "GET /api/dcim/devices/ HTTP/1.1", upstream: "uwsgi://unix:///run/nautobot-dev/uwsgi.socket", host: "nautobot-dev-1.example.com"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ozmusiccommented, Feb 3, 2022

I’m not seeing any of the signs of paginated requests in the nginx access logs

192.0.2.55 - - [03/Feb/2022:17:47:54 +0000] "GET /api/dcim/devices/ HTTP/1.1" 504 167 "-" "python-requests/2.24.0"
192.0.2.55 - - [03/Feb/2022:17:48:32 +0000] "GET /api/dcim/interfaces/ HTTP/2.0" 504 167 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0"
192.0.2.55 - - [03/Feb/2022:17:49:14 +0000] "GET /api/ipam/prefixes/ HTTP/2.0" 200 402963 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/20100101 Firefox/96.0"
192.0.2.55 - - [03/Feb/2022:17:50:02 +0000] "GET /api/ipam/prefixes/ HTTP/1.1" 200 235553 "-" "python-requests/2.24.0"
0reactions
ozmusiccommented, Feb 15, 2022

@glennmatthews sure, I’m happy to close this out

Read more comments on GitHub >

github_iconTop Results From Across the Web

Call to dcim.devices.all() fails with a 504 when using nginx ...
Call to dcim.devices.all() fails with a 504 when using nginx and uwsgi #1329. Environment. Python version: 3.8.11; Nautobot version: 1.2.
Read more >
nginx and uWSGI gives "504 Gateway timeout" - Stack Overflow
I use the unmodified version of uwsgi_params , from the tutorial: uwsgi_param QUERY_STRING $query_string; uwsgi_param REQUEST_METHOD $ ...
Read more >
504 Gateway Time-out uwsgi + nginx django application
This solution addresses 90% of 504 error caused in different scenarios. Your project conf should be same as you've mentioned above.
Read more >
How to Fix 504 Gateway Timeout Error in NGINX - Ubiq BI
Log into your proxy server and try connecting to your web server using curl/ping command.
Read more >
Django Uwsgi Nginx 504 Gateway Timeout | TimOnWeb
I had a long running process (data import) and encountered 504 Gateway Timeout error. I use Nginx / uwsgi pair to serve my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found