[Django] EC2 내부의 PostgreSQL을 localhost에서 접근 등

나의 재물운? 연애운은?

AI가 봐주는 내 사주팔자 - 운세박사

https://aifortunedoctor.com/

[Django] EC2 내부의 PostgreSQL을 localhost에서 접근 등

영리치 0 2,013 2022.01.17 18:55

could not connect to server: Connection refused
Is the server running on host "ompute.amazonaws.com" () and accepting
TCP/IP connections on port 5432?혹시 EC2에 PostgreSQL 설치해서 쓰고 있는데, 이런 에러가 뜨는 데 혹시 해결방법 아시나요~? 


EC2에서 PostgreSQL 인바운드 규칙 열어주기


그 밖에 다른 에러 뜨면 아래 링크들 참고해서 PostgreSQL 설정 열어주기



https://hgko1207.github.io/2020/09/11/postgresql-2/https://mozi.tistory.com/570 


위에 config 파일 수정 후에 아래와 같이 postgresql을 다시 껐다 켜준다.

ubuntu@/etc/postgresql/12/main$ sudo service postgresql restart
ubuntu@/etc/postgresql/12/main$ sudo service postgresql status
 


You have 2 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): chat, feed.

Run 'python manage.py migrate' to apply them.


로컬에서 접속 후에 위와 같이 에러가 뜨는 경우가 있다

위의 경우에는 local에서의 migrations 파일과 서버 내의 migrations 파일이 달라서이다.


이때에는 로컬의 migrations 파일들을 지워주자.


그리고 아래서와 같이 python manage.py migrate를 로컬에서 해주면 잘된다.




TablePlus 앱을 통해 서버에서 구성된 데이터베이스를 직관적으로 시각화하여 볼 수 있다.

1bdc3e62b79d0ee6f231bb9ad3e022c4_1642413235_5032.png
 


python manage.py shell 

위에는 파이썬 명령어 처리


python manage.py dbshell

아래는 PostgreSQL 명령어 처리



Comments

나의 재물운? 연애운은?

AI가 봐주는 내 사주팔자 - 운세박사

https://aifortunedoctor.com/

Category
Magazine
훈남/훈녀
 
 
 
상점
Facebook Twitter GooglePlus KakaoStory NaverBand