admin管理员组

文章数量:1126318

I am working on a vb application using the Npgsql library to connect to a PostgreSQL server. The server is on a Windows machine and I am developing on the same machine. This is my connection string:

 server=192.168.68.11;port=5432;Database=abc123;User ID=user1;Password=password1; 

I believe I was able to get a connection to the database, but I am getting an error:

FATAL: 28000: no pg_hba.conf entry for host "10.174.218.11", user "user1", database "abc123", SSL off

The solution seems to be if I added this line: host all all 0.0.0.0/0 md5 to the pg_hba.conf file.

However, I do not see the file and I do not know where to put the file.

After doing some research, it seems that adding that line is not recommended for security reasons. How do I make it so that only user1 has access?

To summarize: 1. Where do I put the pg_hba.conf file? 2. How do I secure it to only, user1?

I am working on a vb.net application using the Npgsql library to connect to a PostgreSQL server. The server is on a Windows machine and I am developing on the same machine. This is my connection string:

 server=192.168.68.11;port=5432;Database=abc123;User ID=user1;Password=password1; 

I believe I was able to get a connection to the database, but I am getting an error:

FATAL: 28000: no pg_hba.conf entry for host "10.174.218.11", user "user1", database "abc123", SSL off

The solution seems to be if I added this line: host all all 0.0.0.0/0 md5 to the pg_hba.conf file.

However, I do not see the file and I do not know where to put the file.

After doing some research, it seems that adding that line is not recommended for security reasons. How do I make it so that only user1 has access?

To summarize: 1. Where do I put the pg_hba.conf file? 2. How do I secure it to only, user1?

Share Improve this question edited 2 days ago Joel Coehoorn 415k114 gold badges577 silver badges813 bronze badges asked Jan 8 at 22:35 Peter SunPeter Sun 1,8034 gold badges31 silver badges57 bronze badges 2
  • What is the connection string in vb.net? – Joel Coehoorn Commented Jan 8 at 22:43
  • Read pg_hba.conf. – Adrian Klaver Commented Jan 8 at 22:44
Add a comment  | 

1 Answer 1

Reset to default 0

After doing some research, it seems that adding that line is not recommended for security reasons

Correct.

If this is a local connection, within the same computer, the goals is to use the local loopback adapter, so only 127.0.0.1 (or ::1 if on IPv6) is needed (and this is likely already permitted). You may be able to do this by editing the connection string in VB.NET, but I can't tell you what to change since this was not included in the question.

I'd further add that Postgresql is a poor choice for this situation... but I say the same about MySQL, Oracle, and SQL Server as well. These are all server class databases, where the database service is always running and using system resources, even when the application is off. Typically, within a single computer, you want an in-process database engine such as sqlite or even Access.

If this is not a local connection, you want to either limit to the specific host(s) (such as a web server) or subnets that will access the database. You should NOT expect to access a database directly over the public internet. Again, exactly what this looks like depends on more info than we have. One potential option based on the IP in the question is to use 10.0.0.0/8, but if you're already up in the 10.174.x.x range the network is likely also subdivided into vlans, where you may need to be more specific.

本文标签: vbnet Fatal Error when trying to connect to PostgreSQLStack Overflow