How to run pgAdmin 4 with Windows IIS

August 22, 2025

When managing relational databases, especially PostgreSQL, having a user-friendly interface can significantly streamline administration and development tasks. pgAdmin 4 is a powerful, free, open-source graphical management tool designed for PostgreSQL and derivative databases like EnterpriseDB’s EDB Advanced Server.

pgadmin can be installed in two primary modes: Desktop mode, which runs as a standalone application, and Server mode, which enables remote access via a web browser. When deployed in server mode, pgadmin can be hosted behind web servers like Apache2 or Nginx, making it a scalable solution for teams and production environments.

This blog will guide you to set up pgadmin in the server mode behind Windows IIS.

 

A. Setting Up pgAdmin 4 in Server Mode on Windows

To run pgAdmin 4 behind IIS, you'll first need to set it up in server mode.

1. Install Python and pip - 

pgadmin is distributed as a Python package and can be installed using pip. So, before installing pgadmin, ensure Python and pip are available on your Windows system.Download the latest version of Python for Windows from the official Python website. During installation, make sure to check the box that says “Add Python to PATH.” After installation, verify that Python and pip are available by running the following in Command Prompt:

PS C:\Users\Administrator> python --version
Python 3.13.4

PS C:\Users\Administrator> pip --version
pip 25.2 from C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\site-packages\pip (python 3.13)

2. Create a virtual env - 

To keep your pgadmin installation isolated from other Python packages create virtual environment and activate it.

PS C:\Users\Administrator> python -m venv pgadminVenv

PS C:\Users\Administrator> .\pgadminVenv\Scripts\Activate.ps1
(pgadminVenv) PS C:\Users\Administrator>

3. Install pgadmin4 with the pip command - 

(pgadminVenv) PS C:\Users\Administrator> pip install pgadmin4
Collecting pgadmin4
  Downloading pgadmin4-9.7-py3-none-any.whl.metadata (2.8 kB)

 

4. Install the Waitress Python module -

By default, pgadmin uses Werkzeug as Web Server Gateway Interface (WSGI), which is designed for convenience during local development and is not optimized for high traffic or concurrent requests. Waitress is a Python (WSGI) server designed for serving Python web applications in production environments. 

(pgadminVenv) PS C:\Users\Administrator> pip install waitress
Collecting pip

 

B. IIS Installation

1. Navigate to Control Panel and select the 'Turn Windows features on or off' option.

2. Select 'Add Roles and Features' and click Next.

3. Select Role feature-based' installation.

4. Select the server pool and click on Next. Select Web server (IIS) and click Next, and again Next.

5. Here, confirm the modules to install and click on install. On successful installation, close the wizard.

6. Download httpPlatformHandler and install it. HttpPlatformHandler is required to manage and proxy requests to external applications like Python, acting as a reverse proxy to bridge IIS.

7. Open IIS Manager and from the Management section, select 'Configuration Editor'.

8. Select system.webserver, select handler, and click on ‘Unlock section’ from the right panel.

9. Click on 'Add Website' from the sites context menu.

10. Enter website name and select physical path till the 'pgadmin' site package inside the venv.

11. Change binding settings according to your host, port, etc. Uncheck the check box - 'Start website immediately'.

 

C. Deploying pgAdmin behind the IIS web server

To enable access to pgAdmin through IIS, you need to configure IIS as a reverse proxy. This setup allows IIS to forward incoming HTTP(S) requests to the pgAdmin web server. By doing so, you can leverage IIS features such as SSL termination, authentication, and load balancing while securely exposing pgAdmin to users.

1. Copy the pgAdmin4.wsgi file and store the new file as pgAdmin4_wsgi.py alongside the original.

2. Add a web.config file to the directory where pgAdmin4_wsgi.py resides. Below is a typical example of a web.config file.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
<handlers>
         <add name="httpPlatformHandler" 
path="*" 
verb="*" 
modules="httpPlatformHandler" 
resourceType="Unspecified" requireAccess="Script" />
 	</handlers>
      <httpPlatform
		stdoutLogEnabled="true" 
		stdoutLogFile="C:\inetpub\logs\pgadmin\pgadmin.log" 
		startupTimeLimit="10" 
processPath="C:\Users\Administrator\Desktop\pgadminVenv\Scripts\python.exe" 
		arguments="-m waitress --port %HTTP_PLATFORM_PORT% wsgi:application" />
</system.webServer>
</configuration>

3. Make sure your log file location mentioned in above is writable by  user IIS APPPOOL\PgAdmin. (Here - C:\inetpub\logs\pgadmin\ . You may grant permission to a generic user like IIS_IUSRS).

4. Provide Read and execute access to the user IIS APPPOOL\PgAdmin to the Venv folder. (In this case - ‘C:\Users\Administrator\Desktop\pgadminVenv’. Note: The IIS APPPOOL\PgAdmin user will be available only after website creation.)

5. Provide Read and execute access to the user IIS APPPOOL\PgAdmin to the system Python (in this case - C:\Users\Administrator\AppData\Local\Programs\Python\).

6. Create config_local.py in the ….\pgadminVenv\Lib\site-packages\pgadmin4 and add custom path for DATA_DIR and provide full access to directory to IIS APPPOOL\PgAdmin. (e.g. DATA_DIR = "C:\Users\Administrator\Desktop\pgadminDatadir\" )

7. Run the command pgadmin4 in the Python venv and enter the admin email and password.

(pgadminVenv) PS C:\Users\Administrator> pgadmin4
NOTE: Configuring authentication for SERVER mode.

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

Email address: edb@edb.com
Password:
Retype password:
Starting pgAdmin 4. Please navigate to http://127.0.0.1:5050 in your browser.
 * Serving Flask app 'pgadmin'
 * Debug mode: off
(pgadminVenv) PS C:\Users\Administrator>

8. Terminate the process.

 

D. Access pgAdmin 4

Browse the pgadmin from the browser with host:port entered in the bindings. Use the user/email and password entered in the above step for login.

 

Conclusion

By setting up IIS as a reverse proxy to the pgAdmin server, you ensure better integration within Windows environments and enhance accessibility for your users. If you face any issue you can either drop email to pgadmin-support@postgresql.org or raise issue on Github.

 

Share this