Host file and connection issues

Anne 281 Reputation points
2021-07-01T17:55:18.9+00:00

We have a web service long job running overnight that failed occasionally. The error message is An existing connection was for forcibly closed by the remote host.

This web service job runs about 4-5 hrs, and most of time it is successful. Only occasionally it fails. and once it fails, we restarted it, then it succeeded without any problem. The job is
a web service from web server that connect to SQL server database that process each product, so it has many network communication back and forth between web server and database server.

We have checked if the same time, any other jobs could affect, event log, SQL error log, backup, anti-virus, data, network, there are no errors, and we also used fqdn in the web.config, no help. and since it is intermittently fail, it is hard to troubleshoot.
Our system admin suggests to add IP and FQDN name in the host file of windows. But not very clear what to add...

So should I in the web server add in the host file: C:\Windows\System32\drivers\etc\hosts
for example my webserver name is TN_MyWebServer , IP is 10. xx. xx.001 and my database server is TN_MYDBServer1 IP is 10.xx.xx.004

Shall I just add the below line in the web server host ?
10.xx. xx.001 TN_MyWebServer
10.xx. xx.001 TN_MyWebServer. mydomain.com

Currently there is nothing in the host file other than commented out examples.

Do I also need to add database server IP and FQDN in the webserver host file?
Or do I need to add database server IP and FQDN in the database server host file?

Thanks!

Windows for business | Windows Client for IT Pros | Networking | Network connectivity and file sharing
{count} votes

Accepted answer
  1. Dave Woolsey 256 Reputation points
    2021-07-01T18:10:25.083+00:00

    It is as simple as your example shows. You can just add a line that has the IP and the host name following it (after the commented section). It essentially forces the machine to resolve that host name to that IP. I'm not sure it will fix your issue, though. It doesn't seem like it would be related to DNS.

    DB Hosts File
    10.xx. xx.001 TN_MyWebServer
    10.xx. xx.001 TN_MyWebServer. mydomain.com

    Web Server Hosts File
    10.xx. xx.001 TN_MyDBServer
    10.xx. xx.001 TN_MyDBServer. mydomain.com

    1 person found this answer helpful.

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2021-07-01T18:04:39.197+00:00

    You can have both lines (of your example) in there if needed and with no problems. What's important is to have a line in there as server name is referenced in the connection string.

    Do I also need to add database server IP and FQDN in the webserver host file? Or do I need to add database server IP and FQDN in the database server host file?

    add the entries in the hosts file on the server that has the problem running the "web service job"

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.
    0 comments No comments

  2. Anonymous
    2021-07-01T18:16:31.08+00:00

    job is running from the web server

    So yes add the hosts file to this server with the name to ip's that it has connections to. This server should not need lines in there to define its own name to ip

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.
    0 comments No comments

  3. Anonymous
    2021-07-01T18:35:35.983+00:00

    in my this case, the job is running from the web server, shall I just add to the web server the web server IP and FQDN name mappings? Do I also need to add the database server IP into the web server host file or no need?

    Add the database server name to ip in the hosts file on the problem web server. Use the same name as referenced in the web server's connection string.

    If the web server also have other applications that uses different database server, it won't affect them, correct?

    Should not be any effect, you can also add these name to ips as well.

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.
    0 comments No comments

  4. Anne 281 Reputation points
    2021-07-01T18:12:22.773+00:00

    Thanks! I understand this part now quote
    "You can have both lines (of your example) in there if needed and with no problems. What's important is to have a line in there as server name is referenced in the connection string."

    But still not clear:

    in my this case, the job is running from the web server, shall I just add to the web server the web server IP and FQDN name mappings? Do I also need to add the database server IP into the web server host file or no need?
    Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.