{"id":783,"date":"2021-07-08T07:36:19","date_gmt":"2021-07-08T12:36:19","guid":{"rendered":"https:\/\/www.knownhost.com\/kb\/?p=783"},"modified":"2026-01-23T06:22:26","modified_gmt":"2026-01-23T12:22:26","slug":"how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections","status":"publish","type":"post","link":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/","title":{"rendered":"How to configure cPanel MySQL\/MariaDB or PostgreSQL for remote connections?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #212121;color:#212121\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #212121;color:#212121\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#mysqlmariadb\" >MySQL\/MariaDB<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#postgres\" >Postgres<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#restricting_remote_access_further_via_the_firewall\" >Restricting Remote Access Further Via the Firewall<\/a><\/li><\/ul><\/nav><\/div>\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"mysqlmariadb\"><\/span>MySQL\/MariaDB<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It is very simple to set up remote connections in MySQL\/MariaDB thanks to the WHM and <a href=\"https:\/\/docs.cpanel.net\/cpanel\/databases\/remote-mysql\/\">cPanel<\/a> interfaces.<\/p>\n\n\n\n<p>You will need to known advance what IP\/hostname, or IPs\/hostnames, require database access because you will need to specify them in the panel. If your IP is dynamic, you may be able to inquire your ISP about the CDIR range that your IPs are assigned from, and then whitelist that instead. You must use % as a wildcard character if you require the ability to allow connections for all IPs or for a particular subset (you can&nbsp;<em>not<\/em>&nbsp;use the CDIR notation for a subset of IPs but must use the &#8216;%&#8217; wildcard notation instead).<\/p>\n\n\n\n<p>You would first log into WHM as the root user using the following&nbsp;URL&nbsp;first (make sure to replace&nbsp;<em>yourHostName.tld<\/em>&nbsp;with your actual server&#8217;s hostname or IP address):<\/p>\n\n\n\n<p><strong>https:\/\/yourHostName.tld\/whm<\/strong><\/p>\n\n\n\n<p>Navigate to the &#8220;SQL Services&#8221; section and click on &#8220;Additional MySQL Access Hosts&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"176\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts-1024x176.png\" alt=\"\" class=\"wp-image-784\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts-1024x176.png 1024w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts-300x52.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts-768x132.png 768w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can enter the hostnames or IP addresses of the allowed hosts here. You may use a percent sign as a wildcard, so you could add &#8216;192.168.%&#8217; to this list to allow all IPs that begin with &#8216;192.168&#8217;. Click &#8220;Save&#8221; when you have added the IP or fully qualified hostname. The following image shows how to permit remote connections for all IPs (not recommended due to security concerns and shown for demonstration purposes only):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"436\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/allow-all-remoteips-1024x436.png\" alt=\"\" class=\"wp-image-785\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/allow-all-remoteips-1024x436.png 1024w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/allow-all-remoteips-300x128.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/allow-all-remoteips-768x327.png 768w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/allow-all-remoteips.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You will notice at the bottom of this screenshot, the following is stated:<\/p>\n\n\n<div class=\"kb-shortcode kb-shortcode_warning\">\n                    <div class=\"kb-shortcode-icon\">\n                        <i class=\"fa fa-exclamation-triangle fa-2x\"><\/i>\n                    <\/div>\n                    <div class=\"kb-shortcode-content_warning\">Important: Users must log into cPanel and use the Remote MySQL feature to set up access from these hosts. After you have done this, if you would like to configure access from all users\u2019 accounts click here.<\/div>\n                <\/div>\n\n\n\n<p>So, we can either grant the remote location access to all cPanel account&#8217;s databases, or we must then navigate to the cPanel for the cPanel user that requires remote access and allow access to only those databases.<\/p>\n\n\n\n<p>To add remote access for all cPanel accounts, simply click &#8220;click here&#8221; in the statement at the bottom of the &#8220;Additional MySQL Access Hosts&#8221; page as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"393\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/additionalmysqlhostsclickhere-1024x393.png\" alt=\"\" class=\"wp-image-786\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/additionalmysqlhostsclickhere-1024x393.png 1024w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/additionalmysqlhostsclickhere-300x115.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/additionalmysqlhostsclickhere-768x295.png 768w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/additionalmysqlhostsclickhere.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After clicking the &#8216;click here&#8217; option to update the remote access mysql for all cPanel accounts, you will see a confirmation of the users that were updated. On this demonstration server, only two users exist, so only two users were updated:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"800\" height=\"383\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/updatedmysqlhostsforall.png\" alt=\"\" class=\"wp-image-787\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/updatedmysqlhostsforall.png 800w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/updatedmysqlhostsforall-300x144.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/updatedmysqlhostsforall-768x368.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>If we only want to allow access for one cPanel user&#8217;s databases, then we must log into the cPanel account for that user and add the IP(s)\/FQDN(s) there. We can redirect to the cPanel from within WHM here:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Home &gt;&gt; Account Information &gt;&gt; List Accounts<\/code><\/pre>\n\n\n\n<p>Locate the cPanel account you need to enter in the table and click the CP icon for that user. This will open a new window for that cPanel account.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"416\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpredirecticon-1024x416.png\" alt=\"\" class=\"wp-image-788\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpredirecticon-1024x416.png 1024w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpredirecticon-300x122.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpredirecticon-768x312.png 768w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpredirecticon.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once inside the user&#8217;s cPanel, navigate as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  cPanel &gt;&gt; Home &gt;&gt; Databases &gt;&gt; Remote MySQL<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"800\" height=\"441\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanel-remote-mysql.png\" alt=\"\" class=\"wp-image-789\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanel-remote-mysql.png 800w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanel-remote-mysql-300x165.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanel-remote-mysql-768x423.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>This will open the following interface, which shows where to add a new remote MySQL host, and then beneath lists the current hosts that exist already (there may already be one listed and it will be the server&#8217;s main IP):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"428\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/remotemysqlcpanel-1024x428.png\" alt=\"\" class=\"wp-image-790\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/remotemysqlcpanel-1024x428.png 1024w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/remotemysqlcpanel-300x125.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/remotemysqlcpanel-768x321.png 768w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/remotemysqlcpanel.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You will simply enter the same IP(s)\/FQDN(s) here that you entered in WHM&#8217;s &#8220;Additional MySQL Access Hosts&#8221;, and then click &#8221; Add Host&#8221;. Now, this cPanel account can access MySQL on this server from a remote location!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"postgres\"><\/span>Postgres<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While cPanel offers an interface for configuring MySQL for remote connections, it offers no such interface to accomplish the same with Postgresql.<\/p>\n\n\n\n<p>PostgreSQL is a powerful, open source object-relational database system that is known for its ability to scale well. It is configured to listed only on the localhost by default, however, you can simply edit 2 files to specify a remote IP that you&#8217;d also like it to listen for connections from. Here are the default settings that are permitting it to only listen on localhost:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1000\" height=\"126\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postrgres-default-conf.png\" alt=\"\" class=\"wp-image-791\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postrgres-default-conf.png 1000w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postrgres-default-conf-300x38.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postrgres-default-conf-768x97.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>We will need to edit these in addition to specifying the remote IP to allow access for in another file.<\/p>\n\n\n\n<p>First, you need to log into the server as the root user via SSH (remember that Knownhost host uses a non-default port, 2200):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  ssh root@&lt;IP&gt; -p2200<\/code><\/pre>\n\n\n\n<p>Next edit the pg_hba.conf file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  nano \/var\/lib\/pgsql\/data\/pg_hba.conf<\/code><\/pre>\n\n\n\n<p>Then add the following to the bottom of the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  host all all IP.Add.re.ss\/32 md5<\/code><\/pre>\n\n\n\n<p>Replace IP.Add.re.ss with the remote IP that you want to allow. Also, please do not forget to add the CIDR value (block \/32 specifies only a single IP). This CIDR notation is useful when you have a dynamic IP and know the exact range from which IPs are assigned to you. You can add your CIDR here so that those IPs within that specified range are allowed, thus being allowed the remote connection despite the constant reassignment of IPs to you.<\/p>\n\n\n\n<p>You specify md5 if you only want that host to be able to log in using an MD5 encrypted password. Replacing &#8216;md5&#8217; with &#8216;trust&#8217; allows them to connect unconditionally without a password. You may not be able to connect using md5 without having first set up password authentication and a database user, which can be done in cPanel \u00bb Home \u00bb Databases \u00bb PostgreSQL Databases OR in cPanel \u00bb Home \u00bb Databases \u00bb PostgreSQL Database Wizard. The PostgreSQL Database Wizard cPanel inteface will walk you through creating and configuring your Postgres database and user.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"298\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgresqldbwizard-1024x298.png\" alt=\"\" class=\"wp-image-792\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgresqldbwizard-1024x298.png 1024w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgresqldbwizard-300x87.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgresqldbwizard-768x223.png 768w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgresqldbwizard.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once you are comfortable with this, you can use the cPanel interface Home \u00bb Databases \u00bb PostgreSQL Databases to do this instead. This interface contains all functionality on one page and may be quicker to use.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"544\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanelinterfacepostgres-1024x544.png\" alt=\"\" class=\"wp-image-793\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanelinterfacepostgres-1024x544.png 1024w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanelinterfacepostgres-300x160.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanelinterfacepostgres-768x408.png 768w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/cpanelinterfacepostgres.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can specify only a single database or a single user that you&#8217;d wish to allow remote access for as well. The overall syntax of this entry should be as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  host &lt;database name&gt; &lt;database user&gt; &lt;remote access IP address \/32&gt; md5<\/code><\/pre>\n\n\n\n<p>So, if you wanted database user &#8216;alice_whiterabbit&#8217; to be the only user allowed remote access, and then only allow here access to her database &#8216;alice_wonderland&#8217; from her IP 123.45.67.89 via md5 password authentication, you would use the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    host alice_whiterabbit alice_wonderland 123.45.67.89\/32 md5<\/code><\/pre>\n\n\n\n<p>The next file that must be edited is the postgresql.conf file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  nano \/var\/lib\/pgsql\/data\/postgresql.conf<\/code><\/pre>\n\n\n\n<p>Change the line listen_addresses= \u2018localhost\u2019 to the following. You can edit it so that Postgresql accepts connection from any IP address by using a wildcard (*), or you can use comma-separated list of addresses that you want to allow the connections from. I&#8217;d recommend keeping access restricted and only allowing certain IPs access. The following example allows remote connections from all IPs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  listen_addresses= '*'<\/code><\/pre>\n\n\n\n<p>If these edits were being made for alice_whiterabbit, we would append her IP to the default list of addresses that Postgres is already listening on like so:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  listen_addresses='127.0.0.200, localhost,123.45.67.89'<\/code><\/pre>\n\n\n\n<p>Make sure to open the port if it is not already open. If a &#8216;#&#8217; character is at the beginning of the line, remove the &#8216;#&#8217; character to enable the port specification:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  port = 5432<\/code><\/pre>\n\n\n\n<p>Restart the PostgreSQL service with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  service postgresql restart<\/code><\/pre>\n\n\n\n<p>Also, you need to add the PostgreSQL port 5432 on your firewall to allow the connections. You&#8217;ll do this by editing the firewall configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  nano \/etc\/csf\/csf.conf<\/code><\/pre>\n\n\n\n<p>You will append the port number &#8216;5432&#8217; to the TCP_IN and TCP_OUT settings. Then, restart the firewall:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  csf -ra<\/code><\/pre>\n\n\n\n<p>Lastly, you will want to ensure that your firewall doesn&#8217;t start sending false positive alerts about the postgresql process. This is set by default on <a href=\"https:\/\/www.knownhost.com\/\">Knownhost servers<\/a>, but you may want to confirm. If so, you can search for the entry in the file, and if present, then PG is already ignored. If not, then you will want to add it. Use the following command to see if it is already present in the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  grep postgres \/etc\/csf\/csf.pignore<\/code><\/pre>\n\n\n\n<p>If you don&#8217;t get any output from that command, then you will need to add the entry. The image below depicts an ignored Postgres executable:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"800\" height=\"101\" src=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgrespignore.png\" alt=\"\" class=\"wp-image-794\" srcset=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgrespignore.png 800w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgrespignore-300x38.png 300w, https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/postgrespignore-768x97.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>  nano \/etc\/csf\/csf.pignore<\/code><\/pre>\n\n\n\n<p>Add the following to the bottom of the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  exe:\/usr\/bin\/postgres<\/code><\/pre>\n\n\n\n<p>Restart the firewall:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  csf -ra<\/code><\/pre>\n\n\n\n<p>Now, you can test your connection from the remote IP!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"restricting_remote_access_further_via_the_firewall\"><\/span>Restricting Remote Access Further Via the Firewall<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can further secure your remote connections via advanced CSF\/LFD firewall filtering if so desired. You could limit access via the port to that one IP by adding a custom rule like the following to the \/etc\/csf\/csf.allow file for MySQL (replace XXX.XX.XX.XXX with the IP that you want to allow remote access for):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  tcp|in|d=3306|s=XXX.XX.XX.XXX<\/code><\/pre>\n\n\n\n<p>And you would add the following to accomplish this for Postgres:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  tcp|in|d=5432|s=XXX.XX.XX.XXX<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\/MariaDB It is very simple to set up remote connections in MySQL\/MariaDB thanks to the WHM and cPanel interfaces. You will need to known advance what IP\/hostname, or IPs\/hostnames, require database access because you will need to specify them in the panel. If your IP is dynamic, you may be able to inquire your ISP [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[109,186,258,302,303],"class_list":["post-783","post","type-post","status-publish","format-standard","hentry","category-cpanel","tag-cpanel","tag-mysql","tag-phpmyadmin","tag-postgresql","tag-remote-connections"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Configure Remote MySQL\/MariaDB\/PostgreSQL in cPanel | KnownHost<\/title>\n<meta name=\"description\" content=\"Learn how to enable remote database connections in cPanel for MySQL, MariaDB, and PostgreSQL. Includes security settings, IP whitelisting, and access configuration.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configure Remote MySQL\/MariaDB\/PostgreSQL in cPanel | KnownHost\" \/>\n<meta property=\"og:description\" content=\"Learn how to enable remote database connections in cPanel for MySQL, MariaDB, and PostgreSQL. Includes security settings, IP whitelisting, and access configuration.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/\" \/>\n<meta property=\"og:site_name\" content=\"KnownHost\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-08T12:36:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-23T12:22:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"206\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jonathan K. W.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jonathan K. W.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/\"},\"author\":{\"name\":\"Jonathan K. W.\",\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/3db6e20d1f33519cd68fe0ba1230a48b\"},\"headline\":\"How to configure cPanel MySQL\\\/MariaDB or PostgreSQL for remote connections?\",\"datePublished\":\"2021-07-08T12:36:19+00:00\",\"dateModified\":\"2026-01-23T12:22:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/\"},\"wordCount\":1383,\"image\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/accesshosts-1024x176.png\",\"keywords\":[\"cpanel\",\"mysql\",\"phpmyadmin\",\"postgresql\",\"remote connections\"],\"articleSection\":[\"cPanel\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/\",\"url\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/\",\"name\":\"Configure Remote MySQL\\\/MariaDB\\\/PostgreSQL in cPanel | KnownHost\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/accesshosts-1024x176.png\",\"datePublished\":\"2021-07-08T12:36:19+00:00\",\"dateModified\":\"2026-01-23T12:22:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/3db6e20d1f33519cd68fe0ba1230a48b\"},\"description\":\"Learn how to enable remote database connections in cPanel for MySQL, MariaDB, and PostgreSQL. Includes security settings, IP whitelisting, and access configuration.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/accesshosts.png\",\"contentUrl\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/accesshosts.png\",\"width\":1200,\"height\":206},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to configure cPanel MySQL\\\/MariaDB or PostgreSQL for remote connections?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/\",\"name\":\"KnownHost\",\"description\":\"KnownHost provides a comprehensive webhosting knowledge base to help answer many of your common webhosting and linux questions.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.knownhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/3db6e20d1f33519cd68fe0ba1230a48b\",\"name\":\"Jonathan K. W.\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g\",\"caption\":\"Jonathan K. W.\"},\"sameAs\":[\"https:\\\/\\\/www.knownhost.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Configure Remote MySQL\/MariaDB\/PostgreSQL in cPanel | KnownHost","description":"Learn how to enable remote database connections in cPanel for MySQL, MariaDB, and PostgreSQL. Includes security settings, IP whitelisting, and access configuration.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/","og_locale":"en_US","og_type":"article","og_title":"Configure Remote MySQL\/MariaDB\/PostgreSQL in cPanel | KnownHost","og_description":"Learn how to enable remote database connections in cPanel for MySQL, MariaDB, and PostgreSQL. Includes security settings, IP whitelisting, and access configuration.","og_url":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/","og_site_name":"KnownHost","article_published_time":"2021-07-08T12:36:19+00:00","article_modified_time":"2026-01-23T12:22:26+00:00","og_image":[{"width":1200,"height":206,"url":"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts.png","type":"image\/png"}],"author":"Jonathan K. W.","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jonathan K. W.","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#article","isPartOf":{"@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/"},"author":{"name":"Jonathan K. W.","@id":"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b"},"headline":"How to configure cPanel MySQL\/MariaDB or PostgreSQL for remote connections?","datePublished":"2021-07-08T12:36:19+00:00","dateModified":"2026-01-23T12:22:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/"},"wordCount":1383,"image":{"@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#primaryimage"},"thumbnailUrl":"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts-1024x176.png","keywords":["cpanel","mysql","phpmyadmin","postgresql","remote connections"],"articleSection":["cPanel"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/","url":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/","name":"Configure Remote MySQL\/MariaDB\/PostgreSQL in cPanel | KnownHost","isPartOf":{"@id":"https:\/\/www.knownhost.com\/kb\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#primaryimage"},"image":{"@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#primaryimage"},"thumbnailUrl":"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts-1024x176.png","datePublished":"2021-07-08T12:36:19+00:00","dateModified":"2026-01-23T12:22:26+00:00","author":{"@id":"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b"},"description":"Learn how to enable remote database connections in cPanel for MySQL, MariaDB, and PostgreSQL. Includes security settings, IP whitelisting, and access configuration.","breadcrumb":{"@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#primaryimage","url":"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts.png","contentUrl":"https:\/\/www.knownhost.com\/kb\/wp-content\/uploads\/2021\/07\/accesshosts.png","width":1200,"height":206},{"@type":"BreadcrumbList","@id":"https:\/\/www.knownhost.com\/kb\/how-to-configure-cpanel-mysql-mariadb-or-postgresql-for-remote-connections\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.knownhost.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to configure cPanel MySQL\/MariaDB or PostgreSQL for remote connections?"}]},{"@type":"WebSite","@id":"https:\/\/www.knownhost.com\/kb\/#website","url":"https:\/\/www.knownhost.com\/kb\/","name":"KnownHost","description":"KnownHost provides a comprehensive webhosting knowledge base to help answer many of your common webhosting and linux questions.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.knownhost.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b","name":"Jonathan K. W.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g","caption":"Jonathan K. W."},"sameAs":["https:\/\/www.knownhost.com"]}]}},"_links":{"self":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/posts\/783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/comments?post=783"}],"version-history":[{"count":1,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/posts\/783\/revisions"}],"predecessor-version":[{"id":8021,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/posts\/783\/revisions\/8021"}],"wp:attachment":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/media?parent=783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/categories?post=783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/tags?post=783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}