MJPEG camera not working. Getting 502: Bad Gateway


Need help getting my mjpeg camera url from Shinobi (NVR) to work. Basically I have onvif cameras setup in Shinobi. Shinobi then re-streams these as MJPEG based on my setup. I have setup the mjpeg urls in Home Assistant like so.

  - platform: mjpeg
    name: Master Bedroom Camera
    still_image_url: http://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/jpeg/Lts5eDLTRb/1Mvvlxcj2L/s.jpg
    mjpeg_url: http://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/mjpeg/Lts5eDLTRb/1Mvvlxcj2L
    username: user
    password: password
  - platform: mjpeg
    name: Living Room Camera
    still_image_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/jpeg/Lts5eDLTRb/JB4GtuFrVg/s.jpg
    mjpeg_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/mjpeg/Lts5eDLTRb/JB4GtuFrVg
    username: user
    password: password
  - platform: mjpeg
    name: Dining Room Camera
    still_image_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/jpeg/Lts5eDLTRb/JtkUbek22J/s.jpg
    mjpeg_url: https://shinobi-server-url/637F6VzpKDoaTDrPmZGaUhj47Pd9WP/mjpeg/Lts5eDLTRb/JtkUbek22J
    username: user
    password: password

On the UI side, I used Picture Entity Card to view these.

However, it doesn’t show the stream. See screenshot below.


If I paste the shinobi mjpeg url directly in chrome, it works as I can see the stream with no issues.

If I inspect the section using Google Chrome inspect, I get the screenshot below.

I also get the camera url from home assistant.


However, if I paste this url directly to chrome, it gives out the 502: Bad Gateway error.

Here is my Home Assistant setup.

Appreciate any help to fix this.


when you said you paste the url in chrome …and it’s working, how did you enter name and password?
i mean can’t you try add username and password in the url?and remove them from configuration file.

and you should try https://github.com/elad-bar/ha-shinobi


Shinobi creates these urls that has the api key and then they can be used to play the stream directly. For mjpeg stream I can just copy and paste the url in chrome and it will automatically play. For HLS or other type of streams, I will need to use VLC to play them.

I also tried removing user/pass from the config but same issue,

Thanks for the link. I’ll check it out.


For anyone who is experiencing the same issue, mine was caused by an SSL error. Apparently I had certs installed for a certain domain that I used in my Shinobi server and it was causing an issue with my configuration in Home Assistant. Changing the url from ip address to its domain solved the issue.