IlSanto
IlSanto

Reputation: 83

Failed to add client-to-server port forwarding rule on 127.0.0.1:3306

I open the ssh tunnel, with Putty on Windows, setting port 3306 to connect remotely from an external network to the MySql server database on the Ubuntu 14.04 operating system. And I get the following error only on port 3306:

Failed to add client-to-server port forwarding rule on 127.0.0.1:3306: Address is already in use; bind () in ListeningSocket :: StartListening () failed: Windows error 10013: Attempting to access the socket in ways not allowed by the respective access authorizations.

With the other ports ... for example the 5900 and the 2222 the tunnel works correctly and I don't understand why I get the error because I also did the command to check ports on Ubuntu

sudo lsof -i: 3306

and it comes out to me

COMMAND  PID   USER   FD   TYPE  DEVICE  SIZE/OFF  NODE NAME

mysql    8637  mysql  10u  IPv4  37615     0t0     TPC  *: mysql (LISTEN)

What do I have to change to make the tunnel on port 3306 work for me? Thanks in advance

Upvotes: 2

Views: 4830

Answers (3)

朱鸿杰
朱鸿杰

Reputation: 11

I've got the same problem. My bitvise ssh client shows this:

Failed to add client-to-server port forwarding rule on 127.0.0.1:3306: Address is alreadyin use; bind()in ListeningSocket::StartListening()failed: Windows error 10013

At this point, I can't open the cloud databases in my remote server either. It turns out that the local 3306 port was occupied maybe because you have downloaded sql server or something like this. To solve the problem, changing the listen port from 3306 to other big numbers like 2222 may help. Also, don't forget to change the port in HeidiSQL. And it works fine now.

Upvotes: 1

RachelNichols2077
RachelNichols2077

Reputation: 21

A heads up for folks who land here on google.

I had the same error: Failed to add server-to-client port forwarding rule on 127.0.0.1:1433

It turned out I was using the wrong option:

Use S2C when you want to forward a port on your local computer to the remote SSH Server. Example: You want visitors to Server.com:8080 to connect to an app hosted on your local computer, then use S2C.

Use C2S when you want to receive data from the remote server through your local port. Example: You want to visit Server.com:8080 using localhost:8080 on your own computer then use C2S.

So I was using the wrong one. Once I changed to the other one it worked perfectly.

Also you will get the same error if the port is already in use by another application.

So run Windows Command:

netstat -ano -p tcp |find "3306"

Where 3306 is the port number. The command will return the Process ID of the program blocking or using that port. Then run this command to convert the Process ID to a program name.

tasklist |find "1234"

Close that program blocking the port, or try another port that is free.

Failed to add server-to-client port forwarding rule on 127.0.0.1:1433 Bitwise SSH Error

Upvotes: 1

Dawoodjee
Dawoodjee

Reputation: 439

I also had

bitvise failed to add server-to-client port forwarding rule 127.0.0.1:8080: Operation was rejected

I used bitvise and was trying to do a remote port forward. As @IISanto pointed out. This was solved by disabling IPv6 protocal on the initiating Windows machine. This worked fine after:

Client-to-server PF config in bitvise

Upvotes: 2

Related Questions