I have installed PostgreSQL 9.6.1 on a remote Debian 8.1 minimal VM. I am attempting to install pgAdmin4 in server mode so that I am able to access remotely via the web. I have successfully installed pgAdmin4 within a python virtual environment, but an issue arises at one of the final steps of configuration:
Starting pgAdmin 4. Please navigate to http://localhost:5050 in your browser.
Since I do not have a desktop environment installed (nor do I intend on installing one), how can I complete configuration without using localhost
? I have attempted to connect using the server's public IP (e.g. http://80.254.0.132:5050) but am not able to resolve.
I do not have a firewall at the VM or server/NAT level.
I have updated /etc/postgresql/9.6/main/pg_hba.conf
and added host all all 0.0.0.0/0 md5
to the configuration.
I have updated /etc/postgresql/9.6/main/postgresql.conf
and changed listen_addresses = '*'
.
My full steps involved in post-Debian installation (sans new users) looks like the following:
# Initial update.
apt-get install sudo
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y
sudo apt-get install vim -y
# Postgres.
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
# Install PostgreSQL.
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib libpq-dev python-dev
# Set postgres password.
sudo -s
cd ~
sudo -u postgres psql postgres
\password postgres
# Allow remote connections.
sudo vim /etc/postgresql/9.6/main/pg_hba.conf
# host all all 0.0.0.0/0 md5
sudo vim /etc/postgresql/9.6/main/postgresql.conf
# listen_addresses = '*'
sudo service postgresql restart
# Python and pgAdmin.
sudo easy_install pip
sudo pip install virtualenvwrapper
# Create the virtual environment and install pgAdmin.
virtualenv pgadmin4
cd pgadmin4
source bin/activate
sudo apt-get install build-essential libssl-dev libffi-dev python-dev libgmp3-dev
sudo pip install cryptography pyopenssl ndg-httpsclient pyasn1
wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/pip/pgadmin4-1.1-py2-none-any.whl
pip install pgadmin4-1.1-py2-none-any.whl
cp ./lib/python2.7/site-packages/pgadmin4/config.py ./lib/python2.7/site-packages/pgadmin4/config_local.py
python ./lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
By default pgAdmin4 runs on loopback adapter, to make it run on ethernet (eth0) you need to change some of configuration options.
You need to add below config options,
DEFAULT_SERVER = '0.0.0.0'
in config_local.py (in "pgAdmin4" folder).
If also want to change default port then also add
DEFAULT_SERVER_PORT = 8081
Now restart pgAdmin4, Now try accessing pgAdmin4 using IP address you mentioned(eg, http://80.254.0.132:8081), It should work.