Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got a Postgres server that's configured to only allow connections from localhost. I like that.

However, I have a situation where I need to run a database that is accessible from something other than localhost.

Is there any way to set this sort of configuration on a per-database level?

share|improve this question
    
I'm curious why allowing only external connections is preferential. It essentially means you can't properly administer the database from the server it's running on. –  MBraedley Mar 17 at 1:57
    
I guess I wasn't clear - I don't want to disallow localhost, only additionally allow other sources. –  Isaac Dontje Lindell Mar 17 at 16:41
    
Yeah, but that's not what the title says, which is the reason I asked. What you're really asking is "Allow external connections, but only for a specific database". –  MBraedley Mar 17 at 17:05

1 Answer 1

up vote 1 down vote accepted

Yes, this is pretty easy to do.

Just find the pg_hba.conf file your Postgres uses (Mine is in /etc/postgresql/8.4/main but yours may differ, but its the same directory as postgresql.conf is in), and add the appropriate line, for example

host dbname all 1.2.3.4 md5

Will allow any user at 1.2.3.4 to connect to the the database dbname using md5 authentication.

You may need to adjust your firewall rules to allow port 5432 (assuming you run on the default port) through from that machine to your server.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.