omnisharp-server icon indicating copy to clipboard operation
omnisharp-server copied to clipboard

Omnisharp doesn't listen on localhost

Open afiodorov opened this issue 9 years ago • 8 comments

This looks like local misconfiguration, but I can't seem to force mono to listen on localhost instead of remote network:

Stop iptables so that they don't interfere:

sudo systemctl stop iptables.service

Start omnisharp:

/usr/bin/mono /home/tom/.vim/bundle/omnisharp-vim/server/OmniSharp/bin/Debug/OmniSharp.exe -p 2000 -s /home/tom/csharp/playground.sln -v Verbose

Check if I can connect to it:

telnet localhost 2000
Trying ::1...
Connection failed: Connection refused
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

See if port is open

lsof -i TCP| fgrep LISTEN | grep mono
mono      27675  tom    4u  IPv4 6274518      0t0  TCP BLAHBLAH.members.linode.com:cisco-sccp (LISTEN)

Try remote host:

telnet BLAHBLAH.members.linode.com 2000                                                        
Trying /*my remote ip here*/...
Connected to BLAHBLAH.members.linode.com.
Escape character is '^]'.
^]

afiodorov avatar Feb 11 '15 11:02 afiodorov

I think it is listening on localhost.

https://github.com/OmniSharp/omnisharp-server/blob/master/OmniSharp/Program.cs#L127

jtbm37 avatar Apr 13 '15 13:04 jtbm37

You have a localhost entry in /etc/hosts ? On 13 Apr 2015 14:42, "jtbm37" [email protected] wrote:

I think it is listening on localhost.

https://github.com/OmniSharp/omnisharp-server/blob/master/OmniSharp/Program.cs#L127

— Reply to this email directly or view it on GitHub https://github.com/OmniSharp/omnisharp-server/issues/180#issuecomment-92357454 .

nosami avatar Apr 13 '15 15:04 nosami

Oh... do you have an IPv4 entry for localhost?

nosami avatar Apr 13 '15 15:04 nosami

The same problem, I use the OmniSharpSublime for ST3. When I started the ST3, the OmniSharp Server start succeed, but it just LISTEN on my remote IP address, like 192.168.1.11, not on 127.0.0.1(localhost).

This is the result of my telnet try:

`??? ios git:(master) ??? telnet 192.168.1.11 60109 Trying 192.168.1.11... Connected to localhost. Escape character is '^]'. ^] HTTP/1.1 400 Bad Request Content-Type: text/html; charset=us-ascii Server: Mono-HTTPAPI/1.0 Date: Sat, 18 Jun 2016 03:45:19 GMT Content-Length: 52 Connection: close

Bad Request (Invalid request line (parts).)

Connection closed by foreign host. ??? ios git:(master) ??? telnet localhost 60109 Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused Trying ::1... telnet: connect to address ::1: Connection refused Trying fe80::1... telnet: connect to address fe80::1: Connection refused telnet: Unable to connect to remote host ??? ios git:(master) ??? telnet 127.0.0.1 60109 Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused telnet: Unable to connect to remote host ??? ios git:(master) ??? `

lishali12345 avatar Jun 18 '16 04:06 lishali12345

@lishali12345 Check your host file. You need an entry for localhost.

jtbm37 avatar Jun 18 '16 12:06 jtbm37

@jtbm37 Do you mean I need an entry for localhost mapping to my remote ip address like 192.168.1.11? I have an entry for localhost in my hosts file, like this:

127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost

lishali12345 avatar Jun 18 '16 13:06 lishali12345

@lishali12345 what I meant was to make sure you had an entry with localhost pointing to 127.0.0.1 because as you can see in the code linked above the http server will be listening on localhost.

jtbm37 avatar Jun 18 '16 13:06 jtbm37

Yes, I know that. But on my OSX EI Capitan, it just listen on my remote IP address in LAN, not on the local loopback address 127.0.0.1, which can view with the netstat -nat |grep LISTEN.

lishali12345 avatar Jun 18 '16 13:06 lishali12345