Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netcat Server Connection Refused

Using netcat, I need to create a simple server to respond with simple JSON data.

First I am trying with an HTML page:

while true ; do nc -l 8888  < index.html ; done

or even more simply:

netcat -l 8888 < index.html

And then in my browser I do this:

http://localhost:8888/index.html

I also try to connect using netcat:

nc -vz 127.0.0.1 8888

Each of these yields a 'connection refused' result:

localhost [127.0.0.1] 8888 (ddi-tcp-1): Connection refused

How do I resolve this error?

like image 440
JohnMurhy Avatar asked Dec 24 '22 20:12

JohnMurhy


1 Answers

The problem was resolved.

I had to use

netcat -l -p 8888 < index.html

This way I can listen to a localport. Now I it is working.

like image 114
JohnMurhy Avatar answered Dec 27 '22 21:12

JohnMurhy