Running VLC Automatically on a Headless Raspberry Pi

I’ve been setting up a living room stereo with playback with Raspberry Pi. The server runs headless and uses the HTTP interface. Here’s what I did:

0) Install vlc with apt-get install vlc

1) Pick a port and allow it with iptables:

iptables -A INPUT -p tcp --dport 43822 -j ACCEPT

2) Go into your network’s router and give your Raspberry Pi’s MAC address a static DHCP assignment

3) Edit /etc/vlc/lua/http/.hosts to allow connections from the local network (this will depend on your network’s address settings)

4) Generate an M3U playlist and save it to /etc/vlc/playlist.m3u

5) Test vlc by running:

cvlc -I http --http-port 43822 /etc/vlc/playlist.m3u

Using cvlc here will run it purely on the command line. You should now be able to open up a web browser on another machine, go to http://<raspbery pi IP>:43822, and be able to control it from there.

6) VLC refuses to run as root, so create a vlc user with no homedir, password, or shell:

sudo adduser --no-create-home --shell /bin/false --disabled-password vlc

7) Create a script at /etc/vlc/


sudo -u vlc cvlc --http-port ${VLC_PORT} /etc/vlc/streaming.m3u > /dev/null

Make sure to set it chmod +x

(I choose to redirect its output to /dev/null because the SD card that the Raspberry Pi runs off of isn’t going to last long with a lot of log writes.)

8) Run the script command into /etc/rc.local:

/etc/vlc/ &

9) Restart the Raspberry Pi. When it’s finished, you should be able to browse to the same location above and get the controls again.

You can then install an app on your phone like “Remote for VLC” to control it from there, or just use the raw HTML interface in a browser.

Website Pin Facebook Twitter Myspace Friendfeed Technorati Digg Google StumbleUpon Premium Responsive

Bookmark the permalink.

7 Responses to Running VLC Automatically on a Headless Raspberry Pi

  1. squalou says:

    Nice tip !

    just to mention that depending on what you expect from your stereo install, you can also give a try to MPD (music player daemon).
    – a daemon running on the Pi
    – some nice apps on your phone to pilot it.

  2. ADRIAN HARLE says:

    Just what i needed I am using headless VLC for radio audio streamed from my nas running dvblink, and mpd for my music collection, mpd wont play mpeg2

    P.S you also need to user vlc to audio group

    sudo usermod -a -G audio vlc

  3. gfhyang says:

    Great job!!!
    I follow your step and run VLC on my Raspberry Pi very well. Could I add http password on the initial setting? It looks like anyone on the local network could access my vlc.

  4. Tom says:

    VLC auth

    VLC 2.1.0 and later

    Access control has been simplified in VLC 2.1.0. You can restrict access to the web interface by using a simple password that can be set under Tools → Preferences (all) → Interfaces → Main interfaces → Lua → Lua HTTP → Password.

    It can also be set from the command line as the option ‘http-password’, like so:


    When logging in, leave the username field blank.

  5. Akash says:

    Thnks for this article buddy :) helped me a lot

  6. potuz says:

    Do you have xorg-server installed and running on the RPi? I’m trying to get vlc to play on the Pi using DirectFB without any success.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.