Installing pgAdmin4 (4.2) on FreeBSD-12 - SOLVED

Mark Moellering markmoellering at
Sat Feb 9 19:03:10 UTC 2019

Having just done this, I wanted to post this here, in case this will help

This is based off of a Computing For Geeks article by Josphat Mutai, but I
felt there were a couple of pieces missing.
I installed this on my local development machine, "hal" in the examples,
not the postgresql server but I don't think that should change much beyond
the connection definitions once pgadmin4 is up and running.

(original article)

pgadmin4 can use python 2.7 or 3.6  As python 2.7 has an end of life of
Jan, 1 2020, I opted for python 3.6

Pre-Installation Setup

install python36 --                                     pkg install python36
install python pip package manager --     pkg install py36-pip
install python virtualenvironment --        pkg install py36-virtualenv

Installing pgAdmin4

As Root, go to /usr/local

start a python virtual environment for pgadmin4:

root at hal:/usr/local # virtualenv-3.6 pgadmin4

Then run:
 source pgadmin4/bin/activate

This did not work for me, so I had to use:
root at hal:/usr/local # source pgadmin4/bin/activate.csh

Next, load the python dependancies through pip:
[pgadmin4] root at hal:/usr/local #pip install pyopenssl cryptography pyasn1

Then, load sqlite3:
[pgadmin4] root at hal:/usr/local #pkg install py36-sqlite3

Finally, install pgAdmin4 using pip.  Make sure to check for the latest
version and directory:
[pgadmin4] root at hal:/usr/local #pip install
(On my 8-core Ryzen, this took less than a minute.)

Configuration and running

To exit the python virtual environment, run:

I exited the virtual environment at this point, but I don't think it is

next, in the directory:
root at hal:/usr/local/pgadmin4/lib/python3.6/site-packages/pgadmin4

cp to
- and edit the file

around line 140, it will have;

THIS WILL NOT WORK.  You must change it to;
DEFAULT_SERVER = ''         (or a static IP, if you have one)

To run pgAdmin4, you must be in the python virtual environment, and then
run the script;

root at hal:/usr/local # virtualenv-3.6 pgadmin4
root at hal:/usr/local # source pgadmin4/bin/activate.csh
[pgadmin4] root at hal:/usr/local # python

It will ask for an email address and password the first time you run it, as
displayed below;

NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user

Email address: markmoellering at
Retype password:
pgAdmin 4 - Application Initialisation

Starting pgAdmin 4. Please navigate to in your browser.

And it should work (it did for me at any rate).

I went and was able to log in and attach to my remote
server.  When I initially left the DEFAULT_SERVER = '', I could
login but then the web-stie would crash. I changed the setting to
and then worked as expected.  I haven't written an rc
script for it yet but I may in the future.

I hope this helps someone.  While the original instructions by Josphat
Mutai were quite good, there were just a couple of gotchas that I thought
should be explained in more detail

-- Mark

More information about the freebsd-questions mailing list