✓ Solved

root can't bind port 80

On a linode I'm trying to run the darkhttpd web server for my website. For context, darkhttpd is a small http server I'm trying to use for a static site. If darkhttpd is not sophisticated enough to use with Linode, I am willing to switch to a static Apache or nginx or node server.

When I run the darkhttpd server as root, it fails to bind port 80. Some calls to nc showed me I need to specify the ip address as well. So I determined the command should be something like darkhttpd /path/to/wwwroot --port 80 --addr my.linodes.ip.address.

When I run this as root, I get an error:

darkhttpd: bind(port 80): Permission denied

When I set the port to 8080, it works as expected.

Does anyone have any tips to fix this?

3 Replies

✓ Best Answer

I had been using a version of darkhttpd built by the guix package manager because it isn't in the default apt repositories configured by linode. I decided to try building darkhttpd myself, and it works now. I appreciate the help.

If you run it as root can you bind to port 80 (are you trying to set something to listen on a port less than 1024 as a non-root user)?

You said you were running as root I guess. Is there something already listening on port 80? Something like

netstat -tulpn|grep 80

@millisa I checked before posting this question, but I'll check again.

root@localhost:~# netstat -tulpn|grep 80

Here's what it outputs without the grep filter:

root@localhost:~# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0* LISTEN 399/sshd
tcp6 0 0 :::22 :::* LISTEN 399/sshd

As I mentioned, I used nc to verify I need to specify the ip address. Specifically, I used nc -l -p80 and that works fine.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct