By gopokes5326
Hello
I’m trying to make my dockerized React app served by Nginx to connect to backend using the proxy_pass configuration in nginx.conf file and it keep throwing below error.
2021/03/03 23:41:35 [error] 28#28: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.21.0.1, server: 127.0.0.1, request: "POST /authentication/login/ HTTP/1.1", upstream: "http://127.0.0.1:5000/login/", host: "127.0.0.1:8888", referrer: "http://127.0.0.1:8888/login"
Both API backend and containerized React app are running on local. React is running on http://127.0.0.1:8888 and the API is running on http://127.0.0.1:5000.
My nginx.conf file is looking like below
upstream api_server {
server 127.0.0.1:5000;
}
server {
charset UTF-8;
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
server_name 127.0.0.1;
location /authentication/ {
proxy_pass http://api_server/;
}
location / {
try_files $uri /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
I’ve tried different variations of above, but same results. Can anybody suggest me how to resolve this issue?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
It sounds like that the containers might not be connected to one Docker network. You need to make sure that you create a Docker network, and attach all of the containers to that network.
Feel free to share your docker-compose.yaml file here so I could try to advise you further.
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.