Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No connection could be made because the target machine actively refused it #26

Open
SadafShafi opened this issue Sep 25, 2020 · 9 comments

Comments

@SadafShafi
Copy link

I ran this script
import openvpn_api.vpn v = openvpn_api.vpn.VPN('localhost', 7505) v.connect() print(" ______________ connected _______________") print(v.release) v.disconnect()

and this is the error I got
Traceback (most recent call last): File "vpn123.py", line 5, in <module> v.connect() File "C:\Users\sadaf\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openvpn_api\vpn.py", line 63, in connect raise errors.ConnectError(str(e)) from None openvpn_api.util.errors.ConnectError: [WinError 10061] No connection could be made because the target machine actively refused it

@D0han
Copy link
Contributor

D0han commented Sep 25, 2020

Do you have openvpn running and exposing management interface on localhost tcp 7505? Keep in mind any firewalls you may have in place.

@SadafShafi
Copy link
Author

Thanks for the reply
No, i dont have any of such things running along

@Divyanshsingh-dev
Copy link

I am getting the same problem
and I have No Firewall Please HELP!

@HosseyNJF
Copy link

Send your OpenVPN configuration and your code.

@rcolpo
Copy link

rcolpo commented Jan 9, 2021

I also can not connect. My OpenVPN configuration file is located in the current working directory, and in C:\X\OpenVPN\config. The config file is:

client
dev tun
proto udp
remote bcn-239.whiskergalaxy.com 443

nobind
auth-user-pass

resolv-retry infinite

auth SHA512
cipher AES-256-CBC
comp-lzo
verb 2
mute-replay-warnings
remote-cert-tls server
persist-key
persist-tun

key-direction 1
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>

To connect, I'm doing

import openvpn_api
v = openvpn_api.VPN('bcn-239.whiskergalaxy.com', 443)
v.connect()

But I receive a time out error.
I can connect using the OpenVPN GUI, but I would like to have a Python interface.

@HosseyNJF
Copy link

@rcolpo Add another entry to your config like this:
management localhost 7505
And then connect to it this way:
v = openvpn_api.VPN('localhost', 7505)

@rcolpo
Copy link

rcolpo commented Jan 10, 2021

Thank you @HosseyNJF.
I changed the config file like the one below:

client
dev tun
proto udp
remote bcn-239.whiskergalaxy.com 443

management localhost 7505

nobind
auth-user-pass

resolv-retry infinite

auth SHA512
cipher AES-256-CBC
comp-lzo
verb 2
mute-replay-warnings
remote-cert-tls server
persist-key
persist-tun

key-direction 1
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>

Then, I tried to connect like this:

import openvpn_api
v = openvpn_api.VPN('localhost', 7505)
v.connect()

But I got the error:
No connection could be made because the target machine actively refused it

I can no longer connect using the OpenVPN GUI.

@HosseyNJF
Copy link

@rcolpo Are you running both the python code and the OpenVPN server on the same machine?

@shagunkam
Copy link

<openvpn_api.vpn.VPN object at 0x7f85e86d8430>
Traceback (most recent call last):
File "1.py", line 12, in
v.connect()
File "/home/itechnolabs/vpn/env/lib/python3.8/site-packages/openvpn_api/vpn.py", line 63, in connect
raise errors.ConnectError(str(e)) from None
openvpn_api.util.errors.ConnectError: timed out

any help??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants