ERRNO 111 Connection refused when starting server over SSH - python

I would like to start a rpyc server on a machine I'm connected with over ssh. The general SSH connection is working but when starting the server I receive ERRNO 111 Connection refused. When starting the server manually, by logging in via SSH on the machine and starting the py file, I can connect. I tried:
ssh.exec_command("python3 /tmp/recalibration/rpc_service_pictures.py")
ssh.exec_command("python3 /tmp/recalibration/rpc_service_pictures.py &")
ssh.exec_command("nohup python3 /tmp/recalibration/rpc_service_pictures.py &")
ssh.exec_command("nohup python3 /tmp/recalibration/rpc_service_pictures.py > /dev/null 2>&1 &")
but nothing is changing the Connection Problem, any ideas?
Thanks in advance!

Turns out you cant be connected via SSH at the same time.
I had an open SSH session at the same time to debug, and because of that I couldnt connect. Seems obvious when you know it, but if you dont you are completely lost :D

Related

Problem connecting to a Jupyter Notebook on a remote machine

I can ssh into a remote machine.
I then try to connect to a jupyter notebook job that I started on one of the nodes of the remote machine:
ssh -L 8069:localhost:8069 me#remote.machine ssh -L 8069:localhost:8069 me#node14
This has always worked fine in the past.
When I execute this lately, nothing happens until I eventually get a time out message. If I cancel it and then try to simply ssh into the remote machine again, it again does nothing until I get the error message:
ssh: connect to host remote.machine port 22: Connection timed out
I am trying to figure out if this is a problem at my end or at the remote machine. If it's the latter I can't understand why I am able to ssh to the remote machine fine until I try the
ssh -L 8069:localhost:8069 me#remote.machine ssh -L 8069:localhost:8069 me#node14
connection.
You are trying to do a double ssh connection: one to remote.machine and then another one to node14.
The problem seems to be the ssh process in the node14 machine. So, you can connect to the first machine but no to the second one. Ask your administrator to enable the sshd process in node14
You can test this case by logging into remote.machine via:
ssh -L 8069:localhost:8069 me#remote.machine.
Once you get shell access you can try the connection to node14 via:
ssh -L 8069:localhost:8069 me#node14.
According to the description, this last try should fail with the timeout.

Python - error with a simple socket script

So I wrote a script in Python with the module socket but finally he doesn't work. After searching a few hours for an error (I'm new in Python so it's long for me), I didn't find any so instead I wrote another simple script which works with netcat to have a reverse shell between my host machin (Linux) and my VM (Windows).
My command netcat with Linux :
nc -nvlp 4444
My script in Windows :
import socket
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect(("192.168.1.81", 4444))
And after start the listener (netcat), he's listening and after a few seconds, in my Windows machin, the scripts closed itself because he doesn't find anything connection.
I don't know where is the problem, my VM is on the same subnet than my host, I've flushed my iptables in Linux just in case, I'm lost :)
Thanks for your answers !
I just send the script to a friend for trying and it's working, so I think so the problem is in my settings, or somewhere else..

(Pycharm docker setting)Connection refused:no further information

I'm new to Docker. I get a connecting error when trying to setup Docker in PyCharm Professional edition.
I have followed this official manual and turn on the checkbox(Expose daemon on tcp://localhost:2375 without TLS)
But it still not work.
Cannot connect: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.O.O.1:2375
caused by: java.net.ConnectException: Connection refused: no further information
I have accidentally connected docker one time.But when i restart my computer i cannot connect docker anymore.
Any further help would be gratefully appreciated.
If you are facing connection refused then there may be a chance that there is no server to respond to your request.
So first check whether docker server is listening on 2375 port.
netstat -anp tcp | findstr 2375
Or, use tcpview for GUI.
If docker is not listening on this port, then check your C:\ProgramData\Docker\config\daemon.json file and verify whether you have the below Key value pair in your JSON.
"hosts": ["tcp://0.0.0.0:2375"]
If it is not there, then add this and restart your docker daemon.
If you are behind a proxy, then make sure to add this in no-proxy, so that your requests will not be routed via a proxy server.
NOTE: I don't have any experience with docker on windows

PyCharm remote debugging (pydevd) does not connect

PyCharm remote debugging (pydevd) does not connect with the following message:
error: [Errno 10061] No connection could be made because the target machine actively refused it
How can I troubleshoot it?
The output console in PyCharm shows:
Starting debug server at port 21000
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('*.*.*.*', port=21000, suspend=False)
Waiting for process connection...
Server stopped.
I checked the firewall and PyCharm is allowed for both incoming and outgoing connections.
10061 is WSAECONNREFUSED, 'connection refused', which means there was nothing listening at the IP:port you tried to connect to.
Though I see that you have validated its not a firewall issue, but still I would suggest to check the port numbers again with respect to the ones opened in windows firewall. Or to narrow down just run a simplehttpserver or icmp server at the same port and confirm.
In a direct link communication, it often means that you have already something connected to this port.
To check what process is hearing what port, check this SO question.
You can then either kill the program or change the port, depending of what you can do.
Without more information of the "remote tested", it is hard to know what is happening.
I was having the trouble as well (Server stopped as soon as the client connected).
Turned out that I had apparently too many breakpoints defined.
after having removed most of them and re-initiated my remote debug connection from the client (and having restarted the debug server in pycharm) it doesn't trigger anymore the "Server stopped." problem.

why connection always gets refused?

I am trying to connect machine using the RPyC but it always says that connection refused.
I did on the python shell
import rpyc
rpyc.connect("hostname", port)
but it says connection refused. checked the firewall for the port. firewall allow this port.
Try using the exact same versions of both python and rpyc on client and server !
This means that you are not runnin the server side for rpyc
you need to donwload the source code for rpyc from here
https://github.com/tomerfiliba-org/rpyc/releases
then run:
python bin/rpyc_classic.py
where bin is in the source code folder
Once you have that running, you should be able to run the python code without any issues
I hope it works
default server binds to localhost, but the client needs to have hostname 'None' to do this correctly:
rpyc.connect(None, port)

Categories

Resources