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

How connect pgadmin to postgres #2213

Closed
murilolivorato opened this issue Jul 24, 2019 · 23 comments
Closed

How connect pgadmin to postgres #2213

murilolivorato opened this issue Jul 24, 2019 · 23 comments
Labels

Comments

@murilolivorato
Copy link

murilolivorato commented Jul 24, 2019

screen_docker

Hello my friends , does some one can help here to connect pgadmin to postgres ? I dont know What I am doing wrong . Is this configuration right ?
Thanks

@stefnats
Copy link
Contributor

You seem to be using default as hostname in pgadmin.
The correct one may be localhost or 127.0.0.1

@murilolivorato
Copy link
Author

screen_2

Hello @stefnats , I did those changes . but I still cant connect . =/
the password I typed - secret

@lanphan
Copy link
Contributor

lanphan commented Jul 25, 2019

In case you use laradock, hostname should be name of service defined in your docker-compose.yml, postgres (please double check).
You cannot use localhost or 127.0.0.1 here, because pgadmin is in container, and localhost here means 'pgadmin container'.

@murilolivorato
Copy link
Author

hello @lanphan , O used Localhost but it is not working also .
This is my .env configuration -

### POSTGRES ##############################################

POSTGRES_DB=default
POSTGRES_USER=default
POSTGRES_PASSWORD=secret
POSTGRES_PORT=5432

error_3

it showed this error -

Unable to connect to server:

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: Address not available
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?

@lanphan
Copy link
Contributor

lanphan commented Jul 26, 2019

I mean you must use postgres

@murilolivorato
Copy link
Author

hello @lanphan lanphan
Like this -

dbscreen

?
It is not connecting . please some one can help me ? I realy need help .

@lanphan
Copy link
Contributor

lanphan commented Jul 26, 2019

Yes.

Please give me result of this command when you start all your services
docker ps

@murilolivorato
Copy link
Author

hello @lanphan , Thanks for helping .
This is what shows when I type docker ps -

9e46a63bc963        laradock_nginx          "/bin/bash /opt/star…"   2 days ago          Up 8 hours          0.0.0.0:443->443/tcp, 0.0.0.0:8081->80/tcp   laradock_nginx_1
a045d1cdf169        laradock_php-fpm        "docker-php-entrypoi…"   2 days ago          Up 8 hours          9000/tcp                                     laradock_php-fpm_1
1d6f1cf3558b        dpage/pgadmin4:latest   "/entrypoint.sh"         2 days ago          Up 8 hours          443/tcp, 0.0.0.0:5050->80/tcp                laradock_pgadmin_1
6e51acf5b97e        laradock_workspace      "/sbin/my_init"          2 days ago          Up 8 hours          0.0.0.0:2222->22/tcp                         laradock_workspace_1
565c96e4e58e        docker:dind             "dockerd-entrypoint.…"   2 days ago          Up 8 hours          2375/tcp                                     laradock_docker-in-docker_1

@stefnats
Copy link
Contributor

postgres doesn't seem to be running, what command are you using to start laradock with postgres?

@murilolivorato
Copy link
Author

hello @stefnats , thanks for helping .
when I type -

docker-compose restart

it shows -
printdocker

it looks like that postgres is installed , but if I type -

 docker ps

it dont shows anyting about postgres-

 CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                        NAMES
9e46a63bc963        laradock_nginx          "/bin/bash /opt/star…"   4 days ago          Up 10 minutes       0.0.0.0:443->443/tcp, 0.0.0.0:8081->80/tcp   laradock_nginx_1
a045d1cdf169        laradock_php-fpm        "docker-php-entrypoi…"   4 days ago          Up 10 minutes       9000/tcp                                     laradock_php-fpm_1
1d6f1cf3558b        dpage/pgadmin4:latest   "/entrypoint.sh"         4 days ago          Up 10 minutes       443/tcp, 0.0.0.0:5050->80/tcp                laradock_pgadmin_1
6e51acf5b97e        laradock_workspace      "/sbin/my_init"          4 days ago          Up 10 minutes       0.0.0.0:2222->22/tcp                         laradock_workspace_1
565c96e4e58e        docker:dind             "dockerd-entrypoint.…"   4 days ago          Up 10 minutes       2375/tcp                                     larado

I dont know if postgres is installed =/ .

@lanphan
Copy link
Contributor

lanphan commented Jul 29, 2019

Problem here is postgres got problem when starting
Please dig deeper:

  1. Show all containers, including stopped containers:
    docker ps -a
  2. Find the container id of stopped postgres container, get logs:
    docker logs <container id of postgres

Please copy logs here.

From my experience, there are 2 main causes:

  1. Port 5432 on your host computer is already consumed by other process. You can change POSTGRES_PORT to other value
  2. Or, data is already available in ~/.laradock/postgres, and somehow db version is not matched. You can delete that folder and restart postgres.

Then, when you have postgres on, please connect to it by using host postgres

@murilolivorato
Copy link
Author

Hello @lanphan , I typede -

docker logs  laradock_postgres_1

and it showed that -


The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
2019-07-24 18:56:02.129 UTC [47] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
2019-07-24 18:56:02.129 UTC [47] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"
running bootstrap script ... The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
2019-07-25 11:20:26.089 UTC [47] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
2019-07-25 11:20:26.089 UTC [47] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"
running bootstrap script ... The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
2019-07-26 11:44:20.532 UTC [47] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
2019-07-26 11:44:20.532 UTC [47] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"
running bootstrap script ... The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
2019-07-26 19:50:16.173 UTC [47] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
2019-07-26 19:50:16.173 UTC [47] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"
running bootstrap script ... The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default timezone ... UTC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
2019-07-29 11:29:32.642 UTC [47] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
2019-07-29 11:29:32.642 UTC [47] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/data"
running bootstrap script ...

@murilolivorato
Copy link
Author

@lanphan , could you help me via skype ? I dont know how to fix it .
I tryed many things .

Thanks

@lanphan
Copy link
Contributor

lanphan commented Jul 30, 2019

Hi,

Give me your Skype, I'll help.
Please help to prepare AnyDesk, so that I can remotely control your pc.

@stefnats
Copy link
Contributor

Keep us updated about the solution here.

@murilolivorato
Copy link
Author

hello @lanphan , my skype is this one - murilo livorato
Thanks

@claytonferraz
Copy link

no meu caso a porta 5432 estava ocupada. troquei a porta e funcionou.

@iFrancs
Copy link

iFrancs commented Dec 18, 2019

I mean you must use postgres

Thanks, i replace use of localhost or 127.0.0.1 for postgres as Host name

@stale
Copy link

stale bot commented Mar 17, 2020

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Mar 17, 2020
@stale
Copy link

stale bot commented Apr 7, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Apr 7, 2020
@dendihandian
Copy link

@murilolivorato Did you find the solution? I'm having the same problem probably.

@petini96
Copy link

Did you find the solution ?

@samawong
Copy link

Did you find the solution ?

use this username and password when you use pgadmin:
Username : pgadmin4@pgadmin.org
Password : admin

i use the following info to connect postgres when your docker .env use default value :
Hostname: postgres
Database:default
Username: default
Password: secret

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

No branches or pull requests

8 participants