OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Failed connection to server

Open Fujimon416 opened this issue 1 year ago β€’ 5 comments

I followed the description but it didn't work because the server is not reachable. I comformed that Docker is running. Can anyone teach me how to get out of this problem.

image

Fujimon416 avatar Mar 29 '24 16:03 Fujimon416

open the server terminal and press r + enter to refresh the connection

AbdelrahmanHassan111 avatar Mar 29 '24 16:03 AbdelrahmanHassan111

Are there any logs from the server?

rbren avatar Mar 29 '24 20:03 rbren

If you've already troubleshooted server socket status, please ignore below steps.

Here are steps to troubleshoot server connectivity and websocket issues:

  1. Check if the server is listening:

    • Confirm if the server is correctly set up to listen for connections. You can verify this using the following command on Mac and Linux (note: sudo access required):
      lsof -nP -i4TCP:3000
      
    • Example output indicating the server is listening:
      COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
      Python  24241 iamuser  3u  IPv4 123456      0t0  TCP 127.0.0.1:3000 (LISTEN)
      Python  24248 iamuser  3u  IPv4 123456      0t0  TCP 127.0.0.1:3000 (LISTEN)
      
  2. Server console log check:

    • Check the server's output to ensure it's running correctly? You should see something like this:
      uvicorn opendevin.server.listen:app --reload --port 3000
      
    • With the expected output being:
      INFO:     Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit)
      INFO:     Started reloader process [24241] using WatchFiles
      INFO:     Started server process [24248]
      INFO:     Waiting for application startup.
      INFO:     Application startup complete.
      
  3. Testing websocket connection:

    • If the server is listening, try testing a websocket connection using the following commands:
      brew install websocat
      websocat ws://127.0.0.1:3000/ws
      
    • Keep an eye on the server logs for a new websocket connection. The logs should indicate a successful connection:
      INFO:     ('127.0.0.1', 59395) - "WebSocket /ws" [accepted]
      INFO:     connection open
      
  4. Reporting Errors:

    • If you encounter a stack trace due to an exception on the server side after following the above steps, please paste the stack trace here for further analysis.

kvchitrapu avatar Mar 29 '24 21:03 kvchitrapu

If you've already troubleshooted server socket status, please ignore below steps.

Here are steps to troubleshoot server connectivity and websocket issues:

  1. Check if the server is listening:

    • Confirm if the server is correctly set up to listen for connections. You can verify this using the following command on Mac and Linux (note: sudo access required):
      lsof -nP -i4TCP:3000
      
    • Example output indicating the server is listening:
      COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
      Python  24241 iamuser  3u  IPv4 123456      0t0  TCP 127.0.0.1:3000 (LISTEN)
      Python  24248 iamuser  3u  IPv4 123456      0t0  TCP 127.0.0.1:3000 (LISTEN)
      
  2. Server console log check:

    • Check the server's output to ensure it's running correctly? You should see something like this:
      uvicorn opendevin.server.listen:app --reload --port 3000
      
    • With the expected output being:
      INFO:     Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit)
      INFO:     Started reloader process [24241] using WatchFiles
      INFO:     Started server process [24248]
      INFO:     Waiting for application startup.
      INFO:     Application startup complete.
      
  3. Testing websocket connection:

    • If the server is listening, try testing a websocket connection using the following commands:
      brew install websocat
      websocat ws://127.0.0.1:3000/ws
      
    • Keep an eye on the server logs for a new websocket connection. The logs should indicate a successful connection:
      INFO:     ('127.0.0.1', 59395) - "WebSocket /ws" [accepted]
      INFO:     connection open
      
  4. Reporting Errors:

    • If you encounter a stack trace due to an exception on the server side after following the above steps, please paste the stack trace here for further analysis.

I've got same issue, so I followed your guide, and I received the error message as below.

(OpenDevin) root@a451579031d9:/OpenDevin# uvicorn opendevin.server.listen:app --port 3000
INFO:     Started server process [8064]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit)
INFO:     ('127.0.0.1', 52480) - "WebSocket /ws" [accepted]
INFO:     connection open
Please check Docker is running using `docker ps`.
Error! Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Failed to stop container: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Error creating controller.

Error message left on terminal running websocat ws://127.0.0.1:3000/ws

(OpenDevin) root@a451579031d9:/OpenDevin# websocat ws://127.0.0.1:3000/ws
{"error":true,"message":"Error creating controller. Please check Docker is running using `docker ps`."}

hyeonmini avatar Mar 30 '24 00:03 hyeonmini

Thank you for posting advices. Because I am novice, I cannot find server terminal, I cannot find logs. I tried measures shown above, but unfortunately my system is windows11 and I couldn't use "losf" command.

I retried and found that no container is running. "docker ps" command shows no containers running. I assume that this is the main cause of this problem. How do you guys think?

Here's my computer setups: Windows 11 Pro intel Core i5-8400 Mem 40GB

Fujimon416 avatar Mar 30 '24 01:03 Fujimon416

I also have the same problem, running on Ubuntu 22 on WSL2

shahab00x avatar Mar 30 '24 10:03 shahab00x

@hyeonmini In the case of macOS:

  1. Ensure that Docker Desktop is running
  2. In Docker Desktop, under advanced settings check the case β€œAllow the default Docker socket to be used (requires password)”.

This should resolve the issue.

neeleshbisht99 avatar Mar 30 '24 10:03 neeleshbisht99

I also have the same problem, running on Ubuntu 22 on WSL2

@shahab00x , Were able to troubleshoot using https://github.com/OpenDevin/OpenDevin/issues/344#issuecomment-2027840656?

@Fujimon416 , I haven't used Windows machine for a while. Here is a link to understand the commands

Get-NetTCPConnection -State Listen

You want to find if 3000 and 3001 are on the list.

kvchitrapu avatar Mar 30 '24 11:03 kvchitrapu

@neeleshbisht99 has a good point. Check if your OS allows socket.

kvchitrapu avatar Mar 30 '24 11:03 kvchitrapu

I also have the same problem, running on Ubuntu 22 on WSL2

@shahab00x , Were able to troubleshoot using #344 (comment)?

@Fujimon416 , I haven't used Windows machine for a while. Here is a link to understand the commands

Get-NetTCPConnection -State Listen

You want to find if 3000 and 3001 are on the list.

I tried that but everything looks fine. I think the problem is with docker using a different subnet than wsl and the main network. Is there a way to modify uvicorn opendevin.server.listen:app --port 3000 to access the server over the network rather than the localhost?

shahab00x avatar Mar 30 '24 14:03 shahab00x

Is there a way to modify uvicorn opendevin.server.listen:app --port 3000 to access the server over the network rather than the localhost?

Yup! You should be able to add --host 0.0.0.0

rbren avatar Mar 30 '24 14:03 rbren

This is becoming a megathread of failed connections πŸ˜… As such it's probably not super helpful.

If anyone is still stuck, please open a new issue with:

  • The commands you ran to start the app
  • The environment/config variables you used (redacting your API keys)
  • Everything output from uvicorn after running that command
  • A screenshot of the /ws item in the network tab of your browser's console (CMD+Shift+C or CTRL+Shift+C ususally)

rbren avatar Mar 30 '24 15:03 rbren

Is there a way to modify uvicorn opendevin.server.listen:app --port 3000 to access the server over the network rather than the localhost?

Yup! You should be able to add --host 0.0.0.0

Yes! It worked.

I changed the VITE_WS_URL environment variable to the external IP address of WSL export VITE_WS_URL=ws://172.28.215.207:3000/ws and also ran this command uvicorn opendevin.server.listen:app --port 3000 --host 0.0.0.0

shahab00x avatar Mar 30 '24 16:03 shahab00x

I've the same problem on mac m1. I use colima as container. Finally fixed it by soft link the socket file as:

sudo ln -s -f /Users/david/.colima/docker.sock /var/run/docker.sock
sudo chmod +r /var/run/docker.sock

davideuler avatar Mar 31 '24 16:03 davideuler

Great find! Docker socket issue is common. Did you keep the error message that pointed you to the docker socket issue? Sharing it could help others facing the same problem.

On Sun, Mar 31, 2024, 12:40β€―PM david l euler @.***> wrote:

I've the same problem on mac m1. I use colima as container. Finally fixed it by soft link the socket file as:

sudo ln -s -f /Users/david/.colima/docker.sock /var/run/docker.sock sudo chmod +r /var/run/docker.sock

β€” Reply to this email directly, view it on GitHub https://github.com/OpenDevin/OpenDevin/issues/344#issuecomment-2028818280, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKR3B4RNXVUHJW7IZA46MYTY3A4ATAVCNFSM6AAAAABFOTVCE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYHAYTQMRYGA . You are receiving this because you commented.Message ID: @.***>

kvchitrapu avatar Apr 01 '24 02:04 kvchitrapu

We might need an "alternative setups" section for colima, windows, ollama etc

rbren avatar Apr 01 '24 14:04 rbren

Also using Colima on M1. I used the following command before make run:

export DOCKER_HOST=unix://$HOME/.colima/docker.sock

jpshack-at-palomar avatar Apr 06 '24 15:04 jpshack-at-palomar