5

Is it possible to include port numbers in hosts file? Reason that I'm asking is because I have sites that I'm trying to migrate from one hosting server to another, and the sites are pointing to an old SQL server that uses the standard TCP/IP port (1433). On the new server, the SQL Server port is different, and I don't want to change the connection strings for these sites.

Thank you!

mallows98
  • 1,529
  • 4
  • 22
  • 37

5 Answers5

11

This is not possible in the host file. DNS doesn't know anything about port numbers.

Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
  • You are right, it is not possible because I've discovered that hosts files only acts as a pointer to a specific IP address and nothing else. I might go and do the SQL Alias option that Remus Rusanu has suggested. Thanks! – mallows98 Nov 19 '09 at 21:01
6

You can configure an alias in the SQL Configuration Management tool. Is designed to cover exactly this scenario.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
  • 3
    This does not answer the main question: "Is it possible to include port numbers in hosts file?" otherwise, a good answer. – Mims H. Wright Jan 20 '12 at 19:38
2

The hosts file translates host names to IP addresses (and vice-versa). You can't include port numbers.

Phil Ross
  • 25,590
  • 9
  • 67
  • 77
0

You could set up a router to do port forwarding at the new site, and—if not already routed through the router, then give the router's address as the new host.

wallyk
  • 56,922
  • 16
  • 83
  • 148
0

If this helps anyone I definded mine as follows, in the hosts file:

xxx.xxx.xxx.xxx  MyServer

The MyServer works on a specific port.

The when SQL Server 2005 management studio asks for 'server name' when creating a connection, I entered 'Myserver,1234' where 1234 was the port number.

Since it remembers them in a drop down for next time, this was good enough for me.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Tina
  • 1