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

No matter what I do I can't connect to Postgres - HELP #5

Open
coltonshipley opened this issue May 13, 2021 · 3 comments
Open

No matter what I do I can't connect to Postgres - HELP #5

coltonshipley opened this issue May 13, 2021 · 3 comments

Comments

@coltonshipley
Copy link

I'm at a complete loss here. I cannot even continue because for some reason the connection times out. Here are my logs from the run docker-compose up command. This is with the exact docker-compose.yml from part 2. I added the DATABASE_URL string into the error logger function so i could see what it was doing. The only other change I made was putting the server on port 8005 so i could look around with portainer to see if anything popped out. (It didn't)

I have even tried to clone the entire part2 from github and I get the same result. This is being done on Ubuntu.

server_1 | INFO: Uvicorn running on http://0.0.0.0:8005 (Press CTRL+C to quit)
server_1 | INFO: Started reloader process [1]
server_1 | INFO: Started server process [9]
server_1 | INFO: Waiting for application startup.
db_1 | The files belonging to this database system will be owned by user "postgres".
db_1 | This user must also own the server process.
db_1 |
db_1 | The database cluster will be initialized with locale "en_US.utf8".
db_1 | The default database encoding has accordingly been set to "UTF8".
db_1 | The default text search configuration will be set to "english".
db_1 |
db_1 | Data page checksums are disabled.
db_1 |
db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1 | creating subdirectories ... ok
db_1 | selecting dynamic shared memory implementation ... posix
db_1 | selecting default max_connections ... 100
db_1 | selecting default shared_buffers ... 128MB
db_1 | selecting default time zone ... UTC
db_1 | creating configuration files ... ok
db_1 | running bootstrap script ... ok
db_1 | sh: locale: not found
db_1 | 2021-05-13 20:51:35.703 UTC [30] WARNING: no usable system locales were found
db_1 | performing post-bootstrap initialization ... ok
db_1 | syncing data to disk ... ok
db_1 |
db_1 |
db_1 | Success. You can now start the database server using:
db_1 |
db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1 |
db_1 | initdb: warning: enabling "trust" authentication for local connections
db_1 | You can change this by editing pg_hba.conf or using the option -A, or
db_1 | --auth-local and --auth-host, the next time you run initdb.
db_1 | waiting for server to start....2021-05-13 20:51:36.140 UTC [35] LOG: starting PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
db_1 | 2021-05-13 20:51:36.146 UTC [35] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2021-05-13 20:51:36.163 UTC [36] LOG: database system was shut down at 2021-05-13 20:51:35 UTC
db_1 | 2021-05-13 20:51:36.173 UTC [35] LOG: database system is ready to accept connections
db_1 | done
db_1 | server started
db_1 |
db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
db_1 |
db_1 | waiting for server to shut down...2021-05-13 20:51:36.230 UTC [35] LOG: received fast shutdown request
db_1 | .2021-05-13 20:51:36.235 UTC [35] LOG: aborting any active transactions
db_1 | 2021-05-13 20:51:36.236 UTC [35] LOG: background worker "logical replication launcher" (PID 42) exited with exit code 1
db_1 | 2021-05-13 20:51:36.236 UTC [37] LOG: shutting down
db_1 | 2021-05-13 20:51:36.276 UTC [35] LOG: database system is shut down
db_1 | done
db_1 | server stopped
db_1 |
db_1 | PostgreSQL init process complete; ready for start up.
db_1 |
db_1 | 2021-05-13 20:51:36.356 UTC [1] LOG: starting PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
db_1 | 2021-05-13 20:51:36.356 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2021-05-13 20:51:36.356 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2021-05-13 20:51:36.372 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2021-05-13 20:51:36.386 UTC [47] LOG: database system was shut down at 2021-05-13 20:51:36 UTC
db_1 | 2021-05-13 20:51:36.394 UTC [1] LOG: database system is ready to accept connections
server_1 | WARNING: --- DB CONNECTION ERROR ---
server_1 | WARNING: postgres://postgres:postgres@db:5432/postgres
server_1 | WARNING:
server_1 | WARNING: --- DB CONNECTION ERROR ---
server_1 | INFO: Application startup complete.

@Jastor11
Copy link
Owner

Yeah that seems frustrating. Especially since that error message is particularly unhelpful.

My recommendation would be to try two things:

First, with the docker container running, attempt to access the database with psql. Something like:

docker-compose exec db psql -h localhost -U postgres --dbname=postgres --port=5432 -W

If you can connect like so, then it's probably not an issue with the database config.

The other thing that might help is to update the docker-compose.yml file to match the port that you're running on, if you switched to 8005.

@coltonshipley
Copy link
Author

so it seems like i can indeed connect to the container with the above command, it askes for a password which i enter 'postgres' and it seems to allow access. So it seems that the two containers just can't communicate with each other for some reason.

@minhlu-i
Copy link

Hello guys, are we have any solution for this issue? I met this problem too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants