PostgreSQL 9.6:pgadmin4未在localhost上打开:5050(Ubuntu 16.04)

时间:2017-01-21 18:24:46

标签: postgresql ubuntu pgadmin

我在Ubuntu 16.04 according to the answer here上安装了PostgreSQL 9.6和 pgadmin4

我正试图用它来运行它:

cd ~/pgadmin4
source bin/activate
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

在终端我看到了这个:

Starting pgAdmin 4. Please navigate to http://localhost:5050 in your browser.

然而在浏览器中它不起作用 - 基本上浏览器说它无法连接。

我已将/etc/postgresql/9.6/main/postgresql.conf修改为:

listen_addresses = '*'

我的/etc/postgresql/9.6/main/pg_hba.conf看起来像这样:

# Database administrative login by Unix domain socket
local   all             postgres                                md5

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5
host all all  0.0.0.0/0 md5

我修改了config_local.py(在“pgAdmin4”文件夹中)以获得此功能:

SERVER_MODE = True
DEFAULT_SERVER = os.environ.get('PGADMIN_SERVER_IP', '0.0.0.0')
DEFAULT_SERVER_PORT = int(os.environ.get('PGADMIN_SERVER_PORT', '5050'))

如何解决这个问题,让pgadmin4在localhost:5050正常工作?

2 个答案:

答案 0 :(得分:0)

这在CentOS中适用于我:

cat /usr/lib/python2.7/site-packages/pgadmin4-web/config_local.py

SERVER_MODE = True
DEFAULT_SERVER='0.0.0.0'

答案 1 :(得分:0)

这是我的config_local.py。适用于流浪汉ubuntu 16.04。

import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions') 
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
SERVER_MODE = True
DEFAULT_SERVER='0.0.0.0'