Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Third Party Mirror - Can't Connect to my Own Server

Discussion in 'Multiplayer' started by YBtheS, Jun 14, 2020.

  1. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    239
    A while back, I had no problem hosting and connecting to my own server using two instances of my game on the same computer. I use "localhost" as the IP. All of a sudden, when I try to connect to my own server I get this message:

    Client Recv: failed to connect to ip=localhost port=7777 reason=System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it.

    Why is this and how do I fix it?
     
    MilenaRocha likes this.
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Whatever the socket error says is always true.
    In your case, the server refused the connection.
    Check your firewall and open ports :)
     
    mystifluent likes this.
  3. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    239
    I've done that. Turning my firewall off yields the same results.
     
  4. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Then something else is refusing the connection :)
     
    mystifluent likes this.
  5. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    239
    Yah I figured, I just can't figure out what it would be.
     
  6. mystifluent

    mystifluent

    Joined:
    Mar 17, 2020
    Posts:
    2
    Even i have the same problem... When i try to connect to my server (using mirror) in another pc, it does not show any result or it just goes back to the main menu !!

    I have also turned off firewall, and the same internet on both pc's, but still no success =(
    I tried to adjust some setting of network HUD and network manager settings but no results.
    This is the error i get :-

    Client Recv: failed to connect to ip=localhost port=7777 reason=System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it.

    I dont understand this error, any help in fixing it would be nice !!
     
  7. BUSSINFROG

    BUSSINFROG

    Joined:
    May 2, 2018
    Posts:
    2
    my problem is that the target machine actively refuses it i disabled firewall but still refused i can connect to my pc on a build and in editor but not on multiple computers... :-C
     
  8. BUSSINFROG

    BUSSINFROG

    Joined:
    May 2, 2018
    Posts:
    2
    to fix this problem you need to put the IP of the other computer instead of the localhost and in the project settings the IP can be found in settings >> network and internet >> status >> properties >> IPv4 adress :)
     
  9. HydrargyrumGames

    HydrargyrumGames

    Joined:
    Jan 14, 2022
    Posts:
    1
    To late for this, but Port 7777 seems to be having some issues on my device as well; I tried Port 8569 at random and it worked completely;
     
  10. mmokhtar4444

    mmokhtar4444

    Joined:
    Feb 21, 2021
    Posts:
    1
    thank you HydrargyrumGames you helped alot !!!
     
  11. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Havent used mirror, but I guess that when you connect to "localhost" it connects to 127.0.0.1
    If it works like that, you cant connect to other computers using that. You said that both computers are on the same network, so you need the ipv4 of the computer you are connecting to.
    Again, I have never used mirror, but this is how it works on networking in general.
     
  12. ikroz89

    ikroz89

    Joined:
    Nov 26, 2022
    Posts:
    1
    Having Same issue . Solution is simple just check out the ip address of Host machine and in client side replace local host with that ip address. for checking ip address command is ipconfig.