Failed to launch front-end Docker container separately
Self Checks
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Provide a description of requested docs changes
Start the front-end Docker container separately cd web && docker build . -t dify-web docker run -it -p 3000:3000 -e CONSOLE_API_URL= http://127.0.0.1:5001 -e APP_API_URL= http://127.0.0.1:5001 dify-web
The deployment of Docker Compose on the server has been completed and can run normally. Stop the original DIY web container and run the command above. When opening the website, an error message appears below
502 Bad Gateway nginx/1.27.1
I found some similar issues and discussions that might help you resolve the "502 Bad Gateway" error when launching the front-end Docker container separately:
-
I can't access localhost/install and get a 502 Bad Gateway after deploying the docker (closed):
-
Solution: Ensure all Docker containers are running and update the Nginx configuration with the correct IP addresses of the
docker-web-1anddocker-api-1containers. Restart the Nginx container to apply the changes [1].
-
Solution: Ensure all Docker containers are running and update the Nginx configuration with the correct IP addresses of the
-
Changes made to frontend not showing up when app run locally using Docker (closed):
-
Solution: Ensure
entrypoint.shis in UNIX format, set the correct environment variables (CONSOLE_URLandAPP_URL), and verify file permissions. Properly configure the Dockerfile to copy and set the entrypoint script [2].
-
Solution: Ensure
-
repack images but 502 bad gateway (closed):
-
Solution: Check application logs, Docker Compose file, and application code. Rebuild the Docker image and restart the Docker containers. Review and correct the
entrypoint.shscript if necessary [3].
-
Solution: Check application logs, Docker Compose file, and application code. Rebuild the Docker image and restart the Docker containers. Review and correct the
To resolve your specific issue, follow these steps:
-
Ensure Containers are Running:
docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' -
Update Nginx Configuration:
- Identify the IP addresses for
docker-web-1anddocker-api-1. - Open the Nginx configuration file located at
dify/docker/nginx/conf.d. - Replace
http://api:5001withhttp://<docker-api-1 IP>:5001andhttp://web:3000withhttp://<docker-web-1 IP>:3000.
- Identify the IP addresses for
-
Restart Nginx:
docker compose restart nginx -
Run the Frontend Container:
docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 dify-web
These steps should help you resolve the "502 Bad Gateway" error by ensuring Nginx forwards requests to the correct IP addresses of the running containers and by properly configuring the frontend service [1][2][3].
To continue talking to Dosu, mention @dosu.
Please attach the container logs as well. What did you changed?
This is done through Docker ps-a and Docker logs 7e8c81f35aec (viewing my-dify-web), where my-dify-web is a locally created image.
I think 502 Bad Gateway is due to the server isn't started up properly.
Using docker images view:
Using Docker PS - a, check that my-dify-web Status is up and in the started state .
If I run the commands docker stop 7e8c81f35aec (stop my-dify-web), docker start e6bf2af75e45 (start langgenius/dify-web: 0.7.3), the webpage will pass through http://localhost:8070/ Can be opened normally. But I want to start the frontend Docker container separately
The above code only modifies a few places for testing, and then runs the command:docker build . -t dify-web
docker run -d -p 3000:3000 -e CONSOLE_API_URL= http://127.0.0.1:5001/ -e APP_API_URL= http://127.0.0.1:5001/ dify-web