LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-23-2016, 07:11 PM   #1
r.stiltskin
Member
 
Registered: Oct 2003
Location: USA
Distribution: Xubuntu, Arch
Posts: 231

Rep: Reputation: 31
Please explain this netcat output


I'm having trouble trying to connect to an ffmpeg stream -- it's giving some "connection refused" errors:
Code:
[tcp @ 0x28d1f60] Connection to tcp://localhost:8080 failed (Connection refused), trying next address
Tue Feb 23 19:01:29 2016 127.0.0.1 - - New connection: GET /webcam.ffm
Tue Feb 23 19:01:29 2016 127.0.0.1 - - [GET] "/webcam.ffm HTTP/1.1" 200 20559
[tcp @ 0x28d4380] Connection to tcp://localhost:8080 failed (Connection refused), trying next address
Tue Feb 23 19:01:29 2016 127.0.0.1 - - New connection: POST /webcam.ffm
and I'm trying to figure out why.

I ran
~ $ nc -z -v localhost 8080

and the output is
Code:
nc: connect to localhost port 8080 (tcp) failed: Connection refused
Connection to localhost 8080 port [tcp/http-alt] succeeded!
Tue Feb 23 19:08:49 2016 127.0.0.1 - - [] " " 200 0
So why is connection refused for tcp but succeeded for tcp/http-alt? What does this output mean?
 
Old 02-23-2016, 09:26 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,886

Rep: Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615
Maybe this. That the port is open for one use because some other process behind it is available?
"
Working Example

Hereís a few basic examples which show how itís used to test network connectivity. Note that extent of the tests is just to check whether the port is listening, and not the nature of the daemon or whether itís working. In every case, Iíll assume once again that our listening host is called ďdavrosĒ.

Test that the Tomcat port (tcp/8080) is listening and accessible

# nc -v davros 8080
Connection to davros 8080 port [tcp/http-alt] succeeded!
"
http://www.terminalinflection.com/us...-connectivity/

Also

"The -z switch prevents sending any data to a TCP connection and very
limited probe data to a UDP connection, and is thus useful as a fast scanning
mode just to see what ports the target is listening on."

So my guess is -v said check and report, -z said don't send any data.
 
Old 02-24-2016, 12:38 AM   #3
r.stiltskin
Member
 
Registered: Oct 2003
Location: USA
Distribution: Xubuntu, Arch
Posts: 231

Original Poster
Rep: Reputation: 31
But why 2 lines of output, the first saying connection refused and the second connection succeeded?
 
Old 02-24-2016, 10:27 AM   #4
jmoore@thebank.com
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Rep: Reputation: Disabled
Check /etc/hosts. I'll bet that localhost resolves to both ::1 (IPv6) and 127.0.0.1 (IPv4) and that your web service is only listening on one of the addresses, probably IPv4, or that the local firewall is blocking access to that port on one of the addresses. When you give netcat the 'localhost' address for a TCP connection it tries every IP address that name resolves to until it gets a connection or has tried them all.

Last edited by jmoore@thebank.com; 02-24-2016 at 10:29 AM.
 
1 members found this post helpful.
Old 02-24-2016, 12:33 PM   #5
r.stiltskin
Member
 
Registered: Oct 2003
Location: USA
Distribution: Xubuntu, Arch
Posts: 231

Original Poster
Rep: Reputation: 31
That seems to be it. Thanks.
 
Old 02-24-2016, 05:47 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,886

Rep: Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615Reputation: 3615
Yea!! Thanks for the solution and update.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get netcat port scan to output to a file jase4867 Linux - Newbie 6 07-10-2012 12:31 AM
Explain the ls -l output anyone splinux Linux - General 2 03-11-2012 04:23 AM
Can any one please explain this output? ishandutta2007 Programming 4 06-23-2010 02:16 AM
explain the output suchi_s Programming 9 11-08-2004 10:07 AM
explain the output c pragti Programming 10 05-28-2004 01:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration