Internal Server Error 500 -- EC2, django, nginx, uwsgi

I'm developing and deploying django based web-app through EC2 with nginx and uwsgi.

Because of developing Front-side (based on react), I send several http request to my server's public IPv4. And the first few moment, my request is normally answered by server. All data is safely delivered to "http://localhost:3000".

But in some reason, after rebooting my EC2 instance, my nginx returned "500 (Internal Server Error)". More detailed information is descripted below.

[log]

  1. /var/nginx/access.log --> any further information than internal server error
3.21.102.102 - - [22/Dec/2022:04:07:08 +0000] "GET /beta/.env HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246" "-"
3.21.102.102 - - [22/Dec/2022:04:07:08 +0000] "GET /beta/.env.local HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246" "-"
3.21.102.102 - - [22/Dec/2022:04:07:09 +0000] "GET /beta/.env.production HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246" "-"
3.21.102.102 - - [22/Dec/2022:04:07:09 +0000] "GET /beta/.env.staging HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246" "-"
3.21.102.102 - - [22/Dec/2022:04:07:09 +0000] "GET /live/.env HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246" "-"
  1. /var/nginx/access.log --> empty

[configure files and django settings.py]

  1. nginx.configure
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        listen       [::]:80;
        server_name  ec2-13-124-193-1.ap-northeast-2.compute.amazonaws.com;
        root         /home/ec2-user/cury_engine;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


         location / {

                include         uwsgi_params;
                uwsgi_pass      unix:/home/ec2-user/cury.sock;

        }

    }

  1. django settings.py
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

WSGI_APPLICATION = 'cury_engine.wsgi.application'


CORS_ORIGIN_WHITELIST = [
    'http://localhost:3000',
    "http://localhost:8000",
    'https://learningwhales-25946.web.app',
    "http://127.0.0.1:8000",
]

[What I tried after reboot server]

  1. sudo systemctl restart nginx
  2. sudo systemctl restart nginx.service
  3. sudo systemctl restart uwsgi (my django server is automatically run server with this command)
  4. sudo systemctl restart uwsgi.service -> I check nginx and uwsgi is running safely. (with sudo systemctl status XXX command)

[What I tried differently to test server status]

  1. postman request --> same result: 500 (Internal Server Error)
  2. curl request inside EC2 instance terminal --> same result: 500 (Internal Server Error)

i expect to recover my server and know how to debug this error

Back to Top