Api connections from react(axios) to nginx(docker/django) doesn’t work. ERR_CONNECTION_REFUSED


This Content is from Stack Overflow. Question asked by Korek_F

I have a problem with connecting my fronted(react/axios) to backend(django) data hosted on VPS using nginx and docker. Problem is weird because I can connect to api by Postman. The issue appears when I try to get data from my frontend(localhost:3000) or from netlify app.

There is nginx code:

    upstream {
    server django_gunicorn:8000;

server {
    listen 80;

    location / {

    location /ws {

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;

    location /static/ {
        alias /static/;

    location /media/ {
        alias /code/media/;



This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?