When pulling up the Docker container to initialize the data source, it reports: org.postgresql.util.PSQLException: The connection attempt failed. The solution

problem overview

Regarding this problem, the blogger encountered it during containerized deployment.

This problem is a problem, but it is not a problem. In order to keep abreast of the company's development strategy and development cultural policy, and cultivate talents for the company, first boldly let colleagues try to operate first, and finally when there is a problem, the blogger will come out and clean up the mess.

When starting the Docker container, the data source initialization failed and the database connection timed out.

org.postgresql.util.PSQLException: The connection attempt failed. ”,

aused by: java.net.SocketTimeoutException: connect timed out ”,

As shown below:

Specific information is as follows:

Solution

If the blogger deploys the operation from the beginning to the end, there will be no problem. Entering the field halfway is really a bit of a brainstorm.

After groping for several hours, it was finally checked that it was caused by a wrong database access port.

Because when our database is deployed, the ports are distinguished,

One is the port for communication between the container inside the container and the cluster between containers,

One is the port for external, public IP access,

The database access port was wrongly written as the external host port, just modify the port. The two commonly used types are as follows:

As shown below:

Under normal circumstances, the two port configurations are the same, that is, the same unified port, but it is configured as a different port by a colleague, and then the host access port is written when accessing, which is really confusing! ! !


Well, when starting the Docker container to initialize the data source, the report: org.postgresql.util.PSQLException: The connection attempt failed. The solution is written here. If you have any questions or encounter any problems, please scan the code You can also leave me a message if you have any questions, and I will answer them in detail. 
Xiehouyu: "Learning together, making progress together", I also hope that everyone will pay more attention to the IT community of CSND.


author: Andy
Contact the author: [email protected]
Source: CSDN (Chinese Software Developer Network)
Original text: https://blog.csdn.net/Hello_World_QWP/article/details/124405845
Copyright Notice: This article is the blogger's original article, please be sure to indicate the source of the blog post when reprinting!

Guess you like

Origin blog.csdn.net/Hello_World_QWP/article/details/124405845