justinbchau / custom-elt-project

108 stars 66 forks source link

elt_script-1 | Error connecting to PostgreSQL: Command '['pg_isready', '-h', 'source_postgres']' returned non-zero exit status 2. #4

Open mdeshon82 opened 5 months ago

mdeshon82 commented 5 months ago

I am getting error below and can not figure out why it can not connect after attempting to apply the database dump

-1 | -- elt_script-1 | ALTER TABLE ONLY public.film_category elt_script-1 | ADD CONSTRAINT film_category_film_id_fkey FOREIGN KEY (film_id) REFERENCES public.films(film_id); elt_script-1 | ALTER TABLE elt_script-1 | -- elt_script-1 | -- PostgreSQL database dump complete elt_script-1 | -- elt_script-1 | Error connecting to PostgreSQL: Command '['pg_isready', '-h', 'source_postgres']' returned non-zero exit status 2. elt_script-1 | Retrying in 5 seconds... (Attempt 1/5) elt_script-1 | Successfully connected to PostgreSQL! elt_script-1 | Starting ELT script... elt_script-1 | Ending ELT script... elt_script-1 exited with code 0

ValantisChatzimagkas commented 4 months ago

@mdeshon82 Hello, I had the same error, and for me what worked is that I went in the docker-compose.yaml and changed:

Change 1: services: source_postgres: image: postgres:latest I changed it to image: postgres:15.7

Change 2 (not sure if needed) In the Dockerfile I changed this: RUN apt-get update && apt-get install -y postgresql-client ---> RUN apt-get update && apt-get install -y postgresql-client-15

I hope it works and that I did not make it work by luck

bglid commented 4 months ago

@ValantisChatzimagkas Your workaround, along with changing '-u' to '-U' in both the dump_command and load_command, fixed this problem for me. I also did both of the changes you listed. Thanks!

ValantisChatzimagkas commented 4 months ago

@bglid great! I am glad it helped