Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurs when port 5432 is occupied by another program, even though DB_PORT in the .env file has been changed to 5433. #14442

Closed
5 tasks done
IncubatorShokuhou opened this issue Feb 27, 2025 · 6 comments
Labels
🐞 bug Something isn't working

Comments

@IncubatorShokuhou
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. install postgres by default, which will occupy port 5432
  2. change DB_PORT in .env to 5433
  3. install dify by docker compose

✔️ Expected Behavior

no error occour

❌ Actual Behavior

Error response from daemon: driver failed programming external connectivity on endpoint docker-db-1 (1d166d9ffdded0d2b66475026ad5033576bfecd3b456ff925d6202bca1c9fdd9): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use
Copy link

dosubot bot commented Feb 27, 2025

Hey @IncubatorShokuhou! I'm here to help you with any bugs, questions, or contributions you have for Dify. Let's work together to solve this issue!

The error occurs because the docker-compose.yaml file is still mapping the host port 5432 to the container's port 5432, despite changing the DB_PORT in the .env file to 5433. The line - '${EXPOSE_DB_PORT:-5432}:5432' in the docker-compose.yaml file is responsible for this mapping.

To resolve the issue, you need to ensure that the EXPOSE_DB_PORT environment variable is set to 5433 in your .env file or directly modify the docker-compose.yaml file to map the correct port:

ports:
  - '5433:5432'

This change will map the host port 5433 to the container's port 5432, resolving the port conflict [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot dosubot bot added the 🐞 bug Something isn't working label Feb 27, 2025
@IncubatorShokuhou
Copy link
Author

IncubatorShokuhou commented Feb 27, 2025

@dosubot So I need to change DB_PORT=5433 and add EXPOSE_DB_PORT=5433 in .env ?

Copy link

dosubot bot commented Feb 27, 2025

Yes, that's correct. You should set both DB_PORT=5433 and EXPOSE_DB_PORT=5433 in your .env file. This ensures that the environment variable EXPOSE_DB_PORT is used to map the correct port in the docker-compose.yaml file. After making these changes, restart your Docker containers to apply the new configuration.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@crazywoola
Copy link
Member

@dosubot So I need to change DB_PORT=5433 and add EXPOSE_DB_PORT=5433 in .env ?

In your case, you only need to modify EXPOSE_DB_PORT . Or kill existing pg instance.

Copy link

dosubot bot commented Feb 27, 2025

Hey @crazywoola! I'm here to help with bugs, technical questions, and engineering knowledge. It looks like you're diving into some configuration details. If you think I should have more to say on this, feel free to reach out to the Dosu Team.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@IncubatorShokuhou
Copy link
Author

IncubatorShokuhou commented Feb 27, 2025

@crazywoola

It works for me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants