POSTGRES CONNTECTION TIMEOUT WHEN USING AN API

261 views
Skip to first unread message

Sunday Iyanu Ajayi

unread,
Jul 6, 2020, 9:08:03 AM7/6/20
to django...@googlegroups.com
I have a database sql function that I am running fine when on the database but once i link the output via an api I created  and test via postman, I get Nginx 502 error and on my postgresql log I get : Çonnection Timeout error.

The sql db function link to a foreign table and pulls some data (between 500-2000 rows)

Please how can I fix this?

Sunday Iyanu Ajayi

unread,
Jul 6, 2020, 9:24:48 AM7/6/20
to django...@googlegroups.com
I get this error from my postgresql log also : could not send data to client: Broken pipe

Dan Madere

unread,
Jul 6, 2020, 8:44:59 PM7/6/20
to Django users
Sounds like nginx is timing out waiting for Django, due to the slow query. You can set proxy_connect_timeout and proxy_read_timeout in your nginx config to allow it to wait longer. Another approach would be to optimize the SQL query and add indexes, to have the query run faster and not cause the timeout.

Dan

Sunday Iyanu Ajayi

unread,
Jul 6, 2020, 9:11:39 PM7/6/20
to django...@googlegroups.com
Yes. I later figured it out after a lot of research.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9a815404-3c51-4a1f-b85d-ba6886dfc9a0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages