Quick Tip: Regain access to PostgreSQL after changing hostname


Userlevel 7
Badge +14

After changing the hostname of your VBR server, you might have issues accessing the integrated PostgreSQL database. For example when creating a new database or restoring configuration, you see the following error: “SSPI authentication failed for User XYZ”

While the database connection itself uses “localhost”, the pg_ident.conf references the hostname itself for administrative access.

So after changing the hostname, you need to replace the old hostname with the new one inside the pg_ident.conf file. Also you can add additional or different users to access the PostgreSQL instance. The default path to this files is “C:\Program Files\PostgreSQL\15\data\”.

There’s a KB article from Veeam which mentions this error. This also includes how to check the PostegreSQL logs: https://www.veeam.com/kb1471


10 comments

Userlevel 7
Badge +17

Great tip Max. Saving this just in case 👍🏻

Userlevel 7
Badge +8

Thank you for the information. @regnor 
It happens for MSSQL instances as well.

There is a special procedure to rename hostname that hosts a standalone MSSQL instance


https://learn.microsoft.com/en-us/sql/database-engine/install-windows/rename-a-computer-that-hosts-a-stand-alone-instance-of-sql-server?view=sql-server-ver16

Userlevel 7
Badge +6

This is good to know that it happens with Postgres as well.  I avoid renaming Veeam servers, but in the instances where I have and am using MSSQL (it’s always been Express, but I suppose if you use an external SQL server and rename that, it would apply as well), there is a database configuration utility that is used to reconnect to the database using the new server name.

https://www.veeam.com/kb2350

 

Userlevel 7
Badge +20

I had to use the very same scenario recently and it works like a charm.  There is also a hack to associate a logged in user to the database as well so that you can install as them.

Userlevel 7
Badge +6

“So after changing the hostname, you need to replace the old hostname with the new one inside the pg_ident.conf file”. Great information, thanks for sharing, @regnor 

Userlevel 7
Badge +14

Well so far I haven't seen any permission issues with MS SQL. Only the database connection would need to be updated after changing the hostnames. But just like @dloseke I would try not to rename the server. Probably the number one use case is my own lab where I forget to change the random generated Windows hostname 😅

Userlevel 7
Badge +6

Very good tip, thank you @regnor 

Userlevel 7
Badge +8

I avoid changing host names as much as possible but cool to know this exists if I do. Nothing like doing a “quick” name change on a request and breaking things😀. 

Ran into this because we used a the random generated server name to restore a customer who got crypto so the default name was WIN-XX - still ended up having to use local administrator to upgrade to 12.1 as couldn’t get the domain account to work even after adding it to the .conf file.

Have different issue, but same solution applies to my problem:

Installed as specific service domain user, then we added 2MFA for RDP and used our personal logins to manage the server and it is not possible to login to the server as previous service account to perform upgrade from 12.0 to 12.1. The solution was just to add mapping for specific domain users to the pg_ident.conf and restart the service.

Thank you @regnor !

Comment