danielbeach / data-engineering-practice

Data Engineering Practice Problems
1.67k stars 468 forks source link

Unable to connect to the Postgres DB #2

Open evan-jasiewicz opened 2 years ago

evan-jasiewicz commented 2 years ago

I ran the commands docker build --tag=exercise-5 . and docker-compose up run and I get this error:

Screen Shot 2022-03-04 at 2 23 10 pm

I noticed when I check the logs for the exercise-5-postgres-1 container it says this:

Screen Shot 2022-03-04 at 2 24 37 pm
danielbeach commented 2 years ago

Hello, Thanks for reaching out. I just pushed a commit to fix this bug. I added a healthcheck wait to the docker-compose command. I tested it and it works fine now. Basically the main image was not waiting for postgres to start up before connecting. Make sure you are using "postgres" for the host and not "localhost". Thanks! Daniel

On Thu, Mar 3, 2022 at 10:25 PM evan-jasiewicz @.***> wrote:

I ran the commands docker build --tag=exercise-5 . and docker-compose up run and I get this error: [image: Screen Shot 2022-03-04 at 2 23 10 pm] https://user-images.githubusercontent.com/77313018/156699064-43d72eac-ac23-424c-99f4-9315fddeee0d.png

I noticed when I check the logs for the exercise-5-postgres-1 container it says this:

[image: Screen Shot 2022-03-04 at 2 24 37 pm] https://user-images.githubusercontent.com/77313018/156699146-68d1e2b4-2636-44f8-a855-420fd1275f22.png

— Reply to this email directly, view it on GitHub https://github.com/danielbeach/data-engineering-practice/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIE3WYKQENETB42UI76HXOTU6GGCFANCNFSM5P4PEQQA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Dan and Crystal Beach

evan-jasiewicz commented 2 years ago

I pulled your changes and when I run main() I get this error:

psycopg2.OperationalError: could not translate host name "postgres" to address: nodename nor servname provided, or not known.

I haven't changed anything and I have run the docker commands as mentioned in the README.

danielbeach commented 2 years ago

Are you running "docker-compose up run"? After building the image from inside the Exercise folder?

On Sun, Mar 6, 2022, 5:08 PM evan-jasiewicz @.***> wrote:

I pulled your changes and when I run main() I get this error:

psycopg2.OperationalError: could not translate host name "postgres" to address: nodename nor servname provided, or not known.

I haven't changed anything and I have run the docker commands as mentioned in the README.

— Reply to this email directly, view it on GitHub https://github.com/danielbeach/data-engineering-practice/issues/2#issuecomment-1060057767, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIE3WYPPLOSJO5YTYIQLT63U6U3GPANCNFSM5P4PEQQA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

evan-jasiewicz commented 2 years ago

Yep, so I am in the Exercise-5 directory. I run the docker build --tag=exercise-5 . command and then the docker-compose up run. Then when I execute the main.py script I get the error I just mentioned above.