210922개발기둝 : [Nestjs, TypeOrm μ—λŸ¬] no pg_hba.conf entry for host, SSL off

2021. 9. 22. 12:08γ†πŸ“” TIL

πŸ“Œ  상황

heroku 에 배포해 놓은 λ°μ΄ν„°λ² μ΄μŠ€μ™€ μ—°κ²°ν•˜λŠ” κ³Όμ •μ—μ„œ λ°œμƒν•œ μ—λŸ¬. κ°œμΈ ν”„λ‘œμ νŠΈ λ°±μ—”λ“œμ™€ λ°μ΄ν„°λ² μ΄μŠ€λ₯Ό ν—€λ‘œμΏ μ— λ°°ν¬μ‹œν‚€κ³  μ—°λ™ν–ˆλ‹€. 

터미널 μ—λŸ¬ 둜그

 

μ²˜μŒμ—” pg_hba.conf κ°€ λ¬Έμ œμΈμ€„ μ•Œμ•˜λŠ”λ°, ꡬ글링을 ν†΅ν•΄μ„œ ν•΄κ²°ν•œ λ°©λ²•μœΌλ‘œ λͺ¨λ“  ν˜ΈμŠ€νŠΈμ™€ ν¬νŠΈλŠ” λ‹€ 열어놓은 μƒνƒœμ˜€λ‹€.

pg_hba_conf νŒŒμΌμ„ μ—¬λŠ” 방법은 λ§₯뢁 κΈ°μ€€μœΌλ‘œ μ΅œμƒλ‹¨ λ£¨νŠΈμ—μ„œ μ•„λž˜ λͺ…λ Ήμ–΄λ₯Ό μž…λ ₯ν•œλ‹€. μ΅œμƒλ‹¨ λ£¨νŠΈλž€ usr 이 μ‘΄μž¬ν•˜λŠ” 루트λ₯Ό λ§ν•œλ‹€.

cd usr/local/var/postgres

 

μ•„λ¬΄νŠΌ pg_hba.conf νŒŒμΌμ—μ„œ μ‹œλ„ν•  수 μžˆλŠ” 방법은 λͺ¨λ‘ λ™μ›ν–ˆμ§€λ§Œ λ™μΌν•œ μ—λŸ¬λ©”μ‹œμ§€λ§Œ λ‚˜μ™”λ‹€. 

 

🍎  SSL off

 

 

Why am I seeing connection errors for my Heroku Postgres database from an unexpected IP address? What are these unauthorized con

Why am I seeing connection errors for my Heroku Postgres database from an unexpected IP address? What are these unauthorized connection attempts? Issue I'm seeing failed connection attempts in my Heroku Postgres logs, but I'm not creating these connections

help.heroku.com

μ—¬κΈ° 링크λ₯Ό 보면 μ™œ ssl μ—λŸ¬κ°€ λ°œμƒν•˜λŠ”μ§€ 원인을 μ„€λͺ…ν•΄μ€€λ‹€.

 

μš°λ¦¬κ°€ 해쀄 것은 κ²°κ΅­ SSL 섀정을 λ³€κ²½ν•˜λŠ” 것인데, typeorm을 μ„€μ •ν•œ ormconfig.json νŒŒμΌμ—μ„œ  SSL 섀정을 μΆ”κ°€ν•΄μ€€λ‹€.

 

βœ…  ormconfing.json

{
  "type": "postgres",
	...
    
    // μ—¬κΈ° μ•„λž˜λ₯Ό μΆ”κ°€ν•΄μ€€λ‹€.
  "ssl": {
    "rejectUnauthorized": false
  }
}

μœ„ 처럼 μ½”λ“œλ₯Ό μˆ˜μ •ν•˜λ©΄ μ–ΌμΆ” ν•΄κ²°λœλ‹€. 

 

ssl off μ—λŸ¬λŠ” ν•΄κ²°λμ§€λ§Œ λ‹€λ₯Έ μ—λŸ¬κ°€ λ°œμƒν•  수 도 μžˆλ‹€.

λ§Œμ•½ ν•΄λ‹Ή μ—λŸ¬λ©”μ‹œμ§€κ°€ relation ... already exists 라면 ormconfig.json μ—μ„œ synchronize 섀정을 μΆ”κ°€ν•˜μ—¬ false 값을 μ£Όλ©΄ λœλ‹€.