Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection to postgres fails from vscode dev container #155

Open
top-on opened this issue Aug 30, 2020 · 7 comments
Open

Connection to postgres fails from vscode dev container #155

top-on opened this issue Aug 30, 2020 · 7 comments
Assignees
Projects

Comments

@top-on
Copy link
Member

top-on commented Aug 30, 2020

When setting up the backend dev environment (hopefully) as documented,
python -m mj migrate fails with:

peewee.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?

This error can be reproduced (on my machine) when running from Python inside the vscode container setup:

import psycopg2
conn = psycopg2.connect(database="muensterjetzt", user='dbuser', password='...', host='localhost', port= '5432')

However, establishing a connection to the database from outside the dev environment (i.e. a usual terminal) works.

Any ideas how I could make sure that the postgres service/container is accessible from within my backend dev container?
@jdemaeyer, did you have to solve this issue?

@jdemaeyer
Copy link
Collaborator

Mhh, I didn't encounter this as I don't use VSCode. @bCyberBasti?

@top-on
Copy link
Member Author

top-on commented Aug 31, 2020

ah, that means that you are running the mj scripts from outside any container, @jdemaeyer?
in that case, I might indeed have to review our VSCode Remote Containers settings with @bCyberBasti.

@bCyberBasti
Copy link
Collaborator

had that, been there 😄

my problem was that i didn't have the right .env file in the backend folder. if you've started the postgres container once without the configuration it "remembers" the initialisation and is in a wrong state.

steps to fix:

  • delete the dev postgres container and its associated volume
  • create the .env file based on .env.example
  • start everything "as normal"
  • it should now work™️

@jdemaeyer
Copy link
Collaborator

ah, that means that you are running the mj scripts from outside any container, @jdemaeyer?

Yeah, I use the Python installation on my host machine with the mj-specific dependencies in a virtual environment

@top-on
Copy link
Member Author

top-on commented Sep 2, 2020

thx for the hint, @bCyberBasti
however, still having the same connection problem from within the Remote Container. :-(
we might have to have a debugging session at some point.

i'll next try @jdemaeyer's approach

@ubergesundheit
Copy link
Member

@ThorbenJensen is this resolved?

@ubergesundheit ubergesundheit added this to Backlog in General Sep 23, 2020
@ubergesundheit
Copy link
Member

@ThorbenJensen and @bCyberBasti will meet and close this after this is resolved

@ubergesundheit ubergesundheit moved this from Backlog to In progress in General Sep 23, 2020
@top-on top-on self-assigned this Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
General
In progress
Development

No branches or pull requests

4 participants