Sql Server replication requires the actual server name to make a connection to the server

I found the solution in the following link http://www.cryer.co.uk/brian/sqlserver/replication_requires_actual_server_name.htm

thankful to Brian Cryer for his useful site

Quoting from the link to avoid link rot:

Cause:

This error has been observed on a server that had been renamed after the original installation of SQL Server, and where the SQL Server configuration function @@SERVERNAME still returned the original name of the server. This can be confirmed by:

select @@SERVERNAME
go

This should return the name of the server. If it does not then follow the procedure below to correct it.

Remedy:

To resolve the problem the server name needs to be updated. Use the following:

sp_addserver 'real-server-name', LOCAL

if this gives an error complaining that the name already exists then use the following sequence:

sp_dropserver 'real-server-name'
go

sp_addserver 'real-server-name', LOCAL
go

If instead the error reported is 'There is already a local server.' then use the following sequence:

sp_dropserver old-server-name
go

sp_addserver real-server-name, LOCAL
go

Where the "old-server-name" is the name contained in the body of the original error.

Stop and restart SQL Server.


There is another solution to this problem, which does not require **sp_dropserver**, **sp_addserver** or server restarting.

Steps:

  1. Read the error message and remember the SERVERNAME which is in quotes.
  2. Run Sql Server Configuration Manager on the machine with Management Studio installed (usually publisher/distributor side);
  3. Expand the Sql Native 10.0 Configuration\Aliases node;
  4. Create a new alias with name SERVERNAME from 1. It should be a NetBIOS machine name or NetBIOS\instance_name for named instances.
  5. Specify the other options for the alias (port, server and protocol).
  6. Repeat 4 and 5 for 32bit native client.
  7. Test. Run Management Studio on the same machine and try to connect to the server (specify alias as server name).

  8. (Optional) Repeat 2 - 7 for all client machines where Management Studio will be used for replication setup.

That's all!


Short answer: check if you're connecting with the wrong network alias through SSMS

For example, your server might accessible as both:

  • MyDataServer
  • MyDataServer.Company.Com

When a replication publication/subscription is created it gets associated with the name used to connect to the server at the time, if you connect using the different alias or fully qualified name it gives you the error stated on the question.

Details: I just ran into this, the answers about changing the @@servername helped me understand the issue, but I didn't have to do that.

Consider this:

The sql server box was setup as {my_system_name}.local.domain

In our network we have a network alias such that {my_system_alias} allows us to reach the server and avoiding having to enter the fully qualified domain name (FQDN).

Sql Server was installed and also a local replication publication was set up while being connected using the {my_system_alias} name.

I then connected to the server using SSMS specifying the FQDN, if I right click on properties for this existing Replication -> Local Publication I get the error: "Sql Server replication requires the actual server name".

All I had to do: reconnect to the server in SSMS using the alias (or the other way around) and it will allow me to see the Replication Publication details.

PS: Phill's comment in another answer is also an alternative, making a hosts file entry that matches the name you need to use for the connection.