Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] Cannot connect to localhost from QTcpSocket to QTcpServer



  • Hi everyone.

    I have strange issue. I wrote network applications. one server and one client. it worked fine until today. but today I have a problem. server started and QTcpServer::listen method returns true(so it listening to host localhost:1234). but from my client and telnet I can't connect to localhost:1234.

    Why? any ideas?



  • OK. Solution was so simple. I am on windows and there is file named hosts on the path C:\Windows\System32\drivers\etc. just edit this file and add this line:

    127.0.0.1 localhost

    Sometimes some application during the installation edits this file and replaces
    127.0.0.1 localhost
    with 0.0.0.0 localhost

    so you need to fix it manually.