Django-plotly-dash Figures unable to show in Django production but able to show in django development

Hi everyone,

I made a dash webpage in django using django-plotly-dash. I have a code logic to get a dash figure updated when a submitted button was clicked. If I get Django dev webserver up and running to test the dash page by clicking the submitted button, the figure can get updated and shown on dash. But when I did the same on Django production, after the submitted button getting clicked, the figure was unable to show on dash. I monitored the webserver console log, the code logic behind was completed and the figure was able to be recreated with new data successfully without any problems.

It’s confirmed that collectionstatic, nginx, gunicorn were updated and restarted.

I was wondering if anyone knows what goes wrong?

Thank you for your response in advance.

Kelvin

Having something work with the development environment, but not in production, is often due to the configuration for serving static files in Django - as well as images this includes the javascript for Dash itself.
Look in the development console of the web browser - are the any errors in the console or failure to load any files?

1 Like

Hi @delsim ,

Like you said, an error below occurred on web browser console right after dash figure was updated successfully:

Do you know what went wrong based on the error? Thank you for your insight in advance.

_dash-update-component:1 
        
        
       Failed to load resource: the server responded with a status of 504 (Gateway Time-out)

dash_renderer.min.js:2 {message: 'Callback error updating capital_performance_graph.figure', html: '<html>\r\n<head><title>504 Gateway Time-out</title><…disable MSIE and Chrome friendly error page -->\r\n'}

You need to look at whatever you have between your web browser and the Django server and see what they are/are not doing. The nginx logs are probably the first place to look; its configuration would be top of my list to check.

Hi @delsim ,

based on the error message found from browser inspect console regarding gateway timeout. I already get the problem fixed by increasing nginx proxy_read_timeout, proxy_connect_timeout, and proxy_send_timeout.

sudo nano /etc/nginx/nginx.conf

add below to nginx.conf

http{
   ...
   proxy_read_timeout 7200;
   proxy_connect_timeout 7200;
   proxy_send_timeout 7200;
   ...
}

then restart nginx

sudo service nginx restart

Dash figure can show up in production now.

Thank you for your insight.

Regards,
Kelvin