简体   繁体   中英

Client can connect to Server on same machine using localhost, but not when IP Address or hostname is used

I'm using VS Express 2012, setting up a simple server and client on a Windows Server 2008R2 machine with all of the latest updates installed. When I have the client try to connect to the running server using "localhost" as the host to connect to, everything works fine. When I have the client try to connect to the running server using the IP address or the actual host name, I see the "No connection could be made because the target machine actively refused it 192.168.5.159:13000 ..." error message. netstat shows my server is listening on the same port as reported in the error message (13000). I've modified the Windows Firewall setting to allow my client and server to communicate through the Windows Firewall. I've added an entry to my Hosts file associating my host name with the IP address. Any suggestions as to what else I can try? All of this is being done on a private (work) network.

Usually when you set up a server, you need to specify the hostname or IP the server listens on. When you initialize a server to use localhost, you can only use localhost to connect to it.

If you want a server to accept requests from every source you need to see if you can use a wildcard to accept all connections. For example 0.0.0.0 is used a lot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM