Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? - node.js

I'm experimenting with Node and socks5-https-client. For some reason, certain Tor hidden service (.onion) sites return with a connection error.
For example, connecting to DuckDuckGo (3g2upl4pq6kufc4m.onion) works and returns HTML.
However, connecting to The Pirate Bay (uj3wazyk5u4hnvtk.onion) or TORCH (xmh57jrzrnw6insl.onion) returns...
Error: SOCKS connection failed. Connection not allowed by ruleset.
What does this error mean? How can I avoid it?
Here's code to reproduce it:
var shttps = require('socks5-https-client');
shttps.get({
hostname: '3g2upl4pq6kufc4m.onion',
path: '',
socksHost: '127.0.0.1',
socksPort: 9150,
rejectUnauthorized: false
}, function(res) {
res.setEncoding('utf8');
res.on('readable', function() {
console.log(res.read()); // Log response to console.
});
});
The error seems to be caused by a 0x02 value in field 2 of the server response.

In summary
The servers you're failing to access don't support HTTPS. In other words, their port 443 is closed. Tor's error message is unhelpful.
If your security needs permit it, you can fix this by falling back to socks5-http-client.
Steps I took to conclude that
Your code got me the same results on 64-bit Linux with Tor 0.2.5.10, socks5-https-client 1.0.1, Node 0.12.0.
I grepped socks5-https-client's codebase for the error and got a hit in the dependency socks5-client on this line. It translates the underlying SOCKS connection's error code to a human-readable message. Wikipedia's explanation of SOCKS5 error codes lines up with that, but is similarly unhelpfully vague
I found a related Tor bug report from 5 years ago complaining about a similar error, from the same type of SOCKS connection. Turns out the error just means the server rejected your connection.
Just to confirm, I tcpinged TPB on port 443 (HTTPS) through Tor. It doesn't reply to TCP SYN, and fails with the same consistently confusing error:
$ torify tcping uj3wazyk5u4hnvtk.onion 443
[Mar 22 22:40:59] ERROR torsocks[18560]: Connection not allowed by ruleset (in socks5_recv_connect_reply() at socks5.c:520)
error: uj3wazyk5u4hnvtk.onion port 443: Software caused connection abort
Their port 80 (HTTP) replies though:
$ torify tcping uj3wazyk5u4hnvtk.onion 80
uj3wazyk5u4hnvtk.onion port 80 open.
Consequently, your code works for me if I use socks5-http-client instead of socks5-https-client.

Related

Ngrok reconnecting (failed to fetch CRL. errors encountered: asn1: structure error: length too large)

I can't run ngrok successfully, I'm using a node.js app with the command
app.listen(3000, () => {
console.log('Listening on port', 3000);
});
but yet everytime I start ngrok using ngrok http 3000, it just show up these error messages
reconnecting (failed to fetch CRL. errors encountered: asn1: structure error: length too large)
reconnecting (jsonHTTP.Lookup: No such host: tunnel.ngrok.com)
reconnecting (resolved tunnel.ngrok.com has no records)
I also got the exact same error.
The problem for me was the internet connection - ngrok requires a stable connection, as soon as I changed the wifi network the problem was solved

Just installed mongodb cant connect to server on Ubuntu 22.04

I just completed an installation of mongodb in my computer and, after starting and enabling it I keep getting the same error:
MongoDB shell version v4.2.23
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2022-11-10T16:25:32.787+0100 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:353:17
#(connect):2:6
2022-11-10T16:25:32.788+0100 F - [main] exception: connect failed
2022-11-10T16:25:32.788+0100 E - [main] exiting with code 1
I uninstalled and installed multiple times and tried solutions that worked for other people in similar posts but I can not make it work.
I have a feeling it have something to do with the port it is looking for (27017) but I do not know how to check if that is the problem and, if so, how to fix it.
Thanks!
Here are a few things to consider:
Check if the MongoDB process is running (you can verify using ps, netstat (check listen port) command in the server.
See if your MongoDB service runs locally. That is because by default, the listen address of MongoDB is localhost/loopback.
Check if the firewall is running and you have allowed the port.
Verify if you are able to use telnet to command the port 27017 from the application server.

connect to DB from nb: could not translate host name to address error

I'm having trouble connecting to a DB from a jupyter nb on a mac.
psycopg2 complains about an OperationalError. My code:
import sqlalchemy as db
# build connection string
connection_string = f"postgresql://{db_cred['username']}:{db_cred['password']}#{db_cred['host']}/{db_cred['database']}"
# create engine
engine = db.create_engine(connection_string)
# connect
conn = engine.connect()
returns
OperationalError: (psycopg2.OperationalError) could not translate host name "db.production.info" to address: nodename nor servname provided, or not known
Needless to say, the DB credentials are correct. The documentation on these errors isn't very helpful, and most proposed solutions revolve around Docker, which I'm not using in this case.
The only exception was this thread, which proposes using the IP address instead of the host name. I did that, and get the following different error:
OperationalError: (psycopg2.OperationalError) connection to server at "192.XXX.XX.XX", port XXXX failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
Any idea what am I doing wrong?
So the problem turned out to be that an SSH tunnel was necessary.
From a shell script, execute the command:
ssh -L 9999:db.production.info:[port number] -N [username]#192.XXX.XX.XX
this will tunnel db.production.info:[port number] to your localhost on port 9999.
You can then adapt the connection string as
'postgresql://username:password#localhost:9999/[the DB name]'

Receiving "EPROTO" when HTTPS requests with Node 10

a few days ago i moved my frontend with NextJS to Vercel and i started experiencing this following intermittent error during build and production server. So i searched all over the internet but i cannot find the solution.
I am receiving the following error when my App tries to make HTTPS request:
Compiled successfully.
09:47:13.026 Automatically optimizing pages...
09:47:15.212 Error at BlogService.getRecentPosts, details: Error: request to https://**masked** failed, reason: write EPROTO 140256911292224:error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1550:SSL alert number 80
09:47:16.629 Error at getStaticProps on Homepage, details: Error: write EPROTO 140657767638848:error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1550:SSL alert number 80
09:47:16.654 Error at BlogService.getRecentPosts, details: Error: request to https:/**masked** failed, reason: write EPROTO 139955108906816:error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1550:SSL alert number 80
The backend destination is using a Nginx with Reverse Proxy with LetsEncrypt Certificate
So anybody can help me? I never experienced this issue
UPDATE
I changed my backend to AWS Api Gateway but the issue remains.
I already changed my frontend to just make Https requests using TLS 1.2, and the error remains intermittent
Anybody help me?

How can I resolve, if EAI_AGAIN error happens on facebook messenger platform?

Our Node.js app for facebook messenger platform threw the following error.
We use "request" module to connect to facebook graph api and the module threw this error. And the problem was resolved without doing anything about 1 hour after I found the problem. So now it's working, but I'm afraid when it'll happen again. Could you teach me this problem and if there is any resolution?
{ Error: getaddrinfo EAI_AGAIN graph.facebook.com:443
at Object.exports._errnoException (util.js:949:11)
at errnoException (dns.js:33:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
code: 'EAI_AGAIN',
errno: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'graph.facebook.com',
host: 'graph.facebook.com',
port: 443 }
Short answer:
This happens when you have lost connection to your DNS server or the DNS settings are wrong (this includes, but is not limited to, complete or partial disconnect from internet).
That is: Please check if your cable or WiFi connection OR your internet provider does not have a (temporary) problem.
Details:
When this happened, I could see in the debugger call stack that the system function getaddrinfo fails. Thus, it seemed like the trivial reason was - the system cannot map the host name to an IP (in your case the host name 'graph.facebook.com" could not be found).
Indeed, when I tried to ping the host name, which I wanted to reach I got the same as ping error like pinging an unknown host:
u#h:~$ ping someunknownhost.xyzdomain
ping: unknown host someunknownhost.xyzdomain
Additionally when, my connectivity to internet recovered and I could ping the host then the problem of node.js also disappeared.

Resources