그저 내가 되었고

👩🏻‍💻배포하면 DB가 안붙을때(ERROR --- Unable to acquire JDBC Connection...) 본문

개발/Linux

👩🏻‍💻배포하면 DB가 안붙을때(ERROR --- Unable to acquire JDBC Connection...)

hyuunii 2024. 2. 9. 13:00

배포 환경에서 DB가 붙지 않아 애를 먹었다.

결론부터 말하면 DB서버의 방화벽 규칙 때문이었다. IP 허용이 필요하다.

 

 

 

에러 로그

2024-02-09T01:23:15.719Z ERROR 3827 --- [nio-8080-exec-3] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
...이하 생략

2024-02-09T01:23:15.723Z WARN 3827 --- [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 08S01

2024-02-09T01:23:15.723Z ERROR 3827 --- [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

2024-02-09T01:23:15.724Z ERROR 3827 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.dao.DataAccessResourceFailureException: Unable to acquire JDBC Connection [Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.] [n/a]] with root cause java.net.SocketTimeoutException: Connect timed out
...이하 생략

 

이상했다. 

로컬에선 잘됐는데....?

.......ㅋㅋㅋㅋㅋㅋㅋ

 

 

암튼 에러를 쭉 봤는데.

The driver has not received any packets from the server.

Unable to acquire JDBC Connection

Connect timed out

 

 

눈에 띈건 이정도.

가능한 경우는 두가지라고 판단했다.

1] 로컬에선 돌아가던게 배포 환경에서는 안돌아가는거니 보안때문에 특정 ip만 허용중인게 아닐까?

2] 서버가 너무 작나?

 

 

2]는 그렇다기엔 코드도 너무 적은 등 가능성이 없어보여 1]에 무게를 두었다.

 

 

 

사용중인 DB 서버의 방화벽 규칙을 확인해보았다.

그랬더니 내 ip만 등록이 되어 있었다.(당연함. 나만 작업하고있으니까..)

 

 

그래서 모든 ip 허용을 위해

(근데 보안상 좋지는 않다고 생각함. 백엔드 서버의 ip만 추가하는 방법이 나을 것 같다. 근데 일단 난 바빠서...;;; 모든 ip를 허용해주었다.)

방화벽 규칙을 아래와 같이 추가한다.

시작 IP 주소: 0.0.0.0
종료 IP 주소: 255.255.255.255

 

 

이렇게 하면 에러 없이 DB가 잘 붙어 작동한다.