<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pedromussato.com/index.php?action=history&amp;feed=atom&amp;title=Allow_remote_connections_on_PostgreSQL</id>
	<title>Allow remote connections on PostgreSQL - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pedromussato.com/index.php?action=history&amp;feed=atom&amp;title=Allow_remote_connections_on_PostgreSQL"/>
	<link rel="alternate" type="text/html" href="https://wiki.pedromussato.com/index.php?title=Allow_remote_connections_on_PostgreSQL&amp;action=history"/>
	<updated>2026-04-12T10:52:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.pedromussato.com/index.php?title=Allow_remote_connections_on_PostgreSQL&amp;diff=245&amp;oldid=prev</id>
		<title>413vhcu1lq0463ob: /* Edit pg_hba.conf */</title>
		<link rel="alternate" type="text/html" href="https://wiki.pedromussato.com/index.php?title=Allow_remote_connections_on_PostgreSQL&amp;diff=245&amp;oldid=prev"/>
		<updated>2025-02-04T13:27:43Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Edit pg_hba.conf&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:27, 4 February 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l20&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This file defines client authentication rules for connecting to the database.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This file defines client authentication rules for connecting to the database.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &lt;/del&gt;&#039;&#039;&#039;Find and modify the authentication rules&#039;&#039;&#039;:  Open &amp;lt;code&amp;gt;pg_hba.conf&amp;lt;/code&amp;gt; (usually in the same directory as &amp;lt;code&amp;gt;postgresql.conf&amp;lt;/code&amp;gt;).  You’ll see entries similar to the following for local connections:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;Find and modify the authentication rules&#039;&#039;&#039;:  Open &amp;lt;code&amp;gt;pg_hba.conf&amp;lt;/code&amp;gt; (usually in the same directory as &amp;lt;code&amp;gt;postgresql.conf&amp;lt;/code&amp;gt;).  You’ll see entries similar to the following for local connections:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IPv4 local connections:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IPv4 local connections:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>413vhcu1lq0463ob</name></author>
	</entry>
	<entry>
		<id>https://wiki.pedromussato.com/index.php?title=Allow_remote_connections_on_PostgreSQL&amp;diff=244&amp;oldid=prev</id>
		<title>413vhcu1lq0463ob: Created page with &quot; To configure PostgreSQL to accept connections from hosts other than &lt;code&gt;localhost&lt;/code&gt;, you&#039;ll need to modify two files:  # &#039;&#039;&#039;&lt;code&gt;postgresql.conf&lt;/code&gt;&#039;&#039;&#039;: This file controls various settings related to the PostgreSQL server. # &#039;&#039;&#039;&lt;code&gt;pg_hba.conf&lt;/code&gt;&#039;&#039;&#039;: This file controls client authentication and permissions (if not configured properly the PostgreSQL instance will accept unauthenticated connections).  Here’s how you can configure both:  === Edit &lt;code&gt;p...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.pedromussato.com/index.php?title=Allow_remote_connections_on_PostgreSQL&amp;diff=244&amp;oldid=prev"/>
		<updated>2025-02-04T13:26:20Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; To configure PostgreSQL to accept connections from hosts other than &amp;lt;code&amp;gt;localhost&amp;lt;/code&amp;gt;, you&amp;#039;ll need to modify two files:  # &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;postgresql.conf&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039;: This file controls various settings related to the PostgreSQL server. # &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;pg_hba.conf&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039;: This file controls client authentication and permissions (if not configured properly the PostgreSQL instance will accept unauthenticated connections).  Here’s how you can configure both:  === Edit &amp;lt;code&amp;gt;p...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
To configure PostgreSQL to accept connections from hosts other than &amp;lt;code&amp;gt;localhost&amp;lt;/code&amp;gt;, you&amp;#039;ll need to modify two files:&lt;br /&gt;
&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;postgresql.conf&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039;: This file controls various settings related to the PostgreSQL server.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;&amp;lt;code&amp;gt;pg_hba.conf&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;&amp;#039;: This file controls client authentication and permissions (if not configured properly the PostgreSQL instance will accept unauthenticated connections).&lt;br /&gt;
&lt;br /&gt;
Here’s how you can configure both:&lt;br /&gt;
&lt;br /&gt;
=== Edit &amp;lt;code&amp;gt;postgresql.conf&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This file controls how PostgreSQL listens for incoming connections.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Find and edit the &amp;lt;code&amp;gt;listen_addresses&amp;lt;/code&amp;gt; setting&amp;#039;&amp;#039;&amp;#039;:  Open &amp;lt;code&amp;gt;postgresql.conf&amp;lt;/code&amp;gt;, typically located in the PostgreSQL data directory (e.g., &amp;lt;code&amp;gt;/var/lib/pgsql/data/&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/etc/postgresql/{version}/main/&amp;lt;/code&amp;gt; depending on your installation).  Search for &amp;lt;code&amp;gt;listen_addresses&amp;lt;/code&amp;gt; (it might be commented out).&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &amp;#039;localhost&amp;#039;&lt;br /&gt;
Change it to:&lt;br /&gt;
 listen_addresses = &amp;#039;*&amp;#039;&lt;br /&gt;
This will allow PostgreSQL to listen on all available network interfaces. If you want to restrict it to specific IP addresses, you can replace &amp;lt;code&amp;gt;&amp;#039;*&amp;#039;&amp;lt;/code&amp;gt; with a comma-separated list of IP addresses, like &amp;lt;code&amp;gt;listen_addresses = &amp;#039;localhost,192.168.1.100&amp;#039;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Edit &amp;lt;code&amp;gt;pg_hba.conf&amp;lt;/code&amp;gt; ===&lt;br /&gt;
This file defines client authentication rules for connecting to the database.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Find and modify the authentication rules&amp;#039;&amp;#039;&amp;#039;:  Open &amp;lt;code&amp;gt;pg_hba.conf&amp;lt;/code&amp;gt; (usually in the same directory as &amp;lt;code&amp;gt;postgresql.conf&amp;lt;/code&amp;gt;).  You’ll see entries similar to the following for local connections:&lt;br /&gt;
&lt;br /&gt;
IPv4 local connections:&lt;br /&gt;
 host    all             all             127.0.0.1/32            md5&lt;br /&gt;
IPv6 local connections:&lt;br /&gt;
 host    all             all             ::1/128                 md5&lt;br /&gt;
To allow remote connections, add a line for the IP addresses or subnets you want to allow. For example, to allow all IP addresses (not recommended for production, but fine for testing), add:&lt;br /&gt;
 host    all             all             0.0.0.0/0               md5&lt;br /&gt;
Or to limit it to a specific subnet (e.g., &amp;lt;code&amp;gt;192.168.1.0/24&amp;lt;/code&amp;gt;):&lt;br /&gt;
 host    all             all             192.168.1.0/24          md5&lt;br /&gt;
&lt;br /&gt;
* Replace &amp;lt;code&amp;gt;md5&amp;lt;/code&amp;gt; with other authentication methods if necessary (like &amp;lt;code&amp;gt;password&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;scram-sha-256&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=== Restart PostgreSQL ===&lt;br /&gt;
After making these changes, restart the PostgreSQL service to apply them:&lt;br /&gt;
 sudo systemctl restart postgresql&lt;br /&gt;
or&lt;br /&gt;
 sudo service postgresql restart&lt;br /&gt;
&lt;br /&gt;
=== Check Firewall Settings (if applicable) ===&lt;br /&gt;
If your server has a firewall enabled, make sure that the port PostgreSQL uses (by default, port 5432) is open for the IP addresses you want to allow.&lt;/div&gt;</summary>
		<author><name>413vhcu1lq0463ob</name></author>
	</entry>
</feed>