I broke my Plex Media Server <palmface>

POST-RESOLUTION UPDATE: Nothing worked to fix things after that script ran amok except for reverting to a backup. Lesson learned.

Server Version#: 1.19.1
Player Version#:

This all started when I was trying to get Remote Access working from behind my VPN and has turned into a bit of a nightmare.

[Under the assumption that these scripts were session-based; i.e. their effects disappeared upon reboot] I wound up running a script that was posted on the forums to try to route Plex traffic around my VPN. Unfortunately, something the script did messed with my Plex configuration resulting in limited functionality (home page was not loading and I had no server info or ability to switch accounts) as in the image below.

I did a repair, got same results. I installed an reinstalled, got same results.

I tried suggestions from the forums on resetting the server, but still had the same behavior.

I figured next step was to go thermonuclear, so I deleted everything in my AppData\Plex folder thinking I could start with a completely clean install and be good. Boy was I wrong. Now all I get is a message stating “Plex is not reachable…” even though I’m accessing it on the actual machine it’s supposed to be running on. Ugh.

Is there a way I can wipe the slate clean? Thanks in advance for any advice and help.

I am also unable to load plex.tv in my browser, despite being able to access other websites just fine, so I think the script somehow re-routed my traffic incorrectly.

The contents of the script are:

@echo off
setlocal
set PATH=%SystemRoot%\system32;%SystemRoot%\system32\wbem;%SystemRoot%
chcp 437>nul

set userProfileDir=C:\Users\homeservices
set gatewayIP=192.168.1.1

title VPN Bypass for Plex Media Server
::chdir /d “%~dp0”
::if not exist support cd…

echo VPN Bypass for Plex Media Server
echo by XFlak
echo.

::echo %userProfileDir%
::echo %gatewayIP%
::goto:end_noexit

::get Default Gateway
::ipconfig|findstr /I /C:“Puerta de enlace predeterminada”|findstr /I /C:“1” >"%temp%\gateway.txt"
::set /p gateway= <"%temp%\gateway.txt"
::set gateway=%gateway:*: =%
::echo %gatewayIP%
::If gateway is detected incorrectly, override it by uncommenting the below like (delete ::slight_smile: and input your correct gateway
::set gateway=192.168.2.1

echo Getting plex.tv’s current IP addresses…
echo.
echo Note: Log of plex.tv’s routed IP’s saved here:
echo %userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt
echo.

::nslookup “plex.tv”|findstr /I /V “Server: Address: Name: timeout” >"%temp%\temp.txt"
nslookup “plex.tv”|findstr /I /V “Server: Servidor: Address: Dirección: Name: Nombre: timeout” >"%temp%\temp.txt"
findstr /I /C:" " “%temp%\temp.txt” >"%temp%\plex.tv.txt"

echo.

cd /d “%temp%”
for /F “tokens=*” %%A in (plex.tv.txt) do call :list %%A
goto:donelist

:list

set PlexIP=%*
set PlexIP=%PlexIP:* =%
echo %PlexIP%

::if not exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” goto:skipcheck
if not exist “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” goto:skipcheck

::findstr /I /C:"%PlexIP%" “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul
findstr /I /C:"%PlexIP%" “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul
IF NOT ERRORLEVEL 1 (echo IP already routed, skipping…) & (goto:EOF)
:skipcheck

echo route -p add %PlexIP% mask 255.255.255.255 %gatewayIP%
::echo route delete %PlexIP% mask 255.255.255.255 %gateway%

::route delete %PlexIP% mask 255.255.255.255 %gateway%
route -p add %PlexIP% mask 255.255.255.255 %gatewayIP%
echo.

::echo %PlexIP% >>"%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt"
echo %PlexIP% >>"%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt"

goto:EOF

:donelist

::clean no longer used IPs

echo.
echo Removing routed IPs no longer used by plex.tv
echo.

::if exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” del “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt”>nul
::if not exist “%userprofile%\AppData\Local\Plex Media Server” goto:doneclean
::if not exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” goto:doneclean
if exist “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” del “%userprofileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt”>nul
if not exist “%userProfileDir%\AppData\Local\Plex Media Server” goto:doneclean
if not exist “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” goto:doneclean

::cd /d “%userprofile%\AppData\Local\Plex Media Server”
cd /d “%userProfileDir%\AppData\Local\Plex Media Server”

for /F “tokens=*” %%A in (PermittedPlexIPs.txt) do call :clean %%A
goto:doneclean

:clean

set PlexIP=%*

findstr /I /C:"%PlexIP%" “%temp%\plex.tv.txt” >nul
IF ERRORLEVEL 1 goto:remove

echo IP still used: %PlexIP%
::echo %PlexIP% >>"%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt"
echo %PlexIP% >>"%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt"

goto:EOF

:remove
echo IP no longer used: route delete %PlexIP%
route delete %PlexIP%

goto:EOF

:doneclean

::if exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” del “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul
::if exist “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” move /y “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” “%userprofile%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul

if exist “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt” del “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul
if exist “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” move /y “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs2.txt” “%userProfileDir%\AppData\Local\Plex Media Server\PermittedPlexIPs.txt”>nul

echo.
echo Finished, exiting…
@ping 127.0.0.1 -n 3 -w 1000> nul

::pause

::exit

:end_noexit

::Other route commands
::route print
::route -p add 54.241.0.0 mask 255.255.0.0 192.168.2.1
::route delete 54.241.0.0 mask 255.255.0.0
::route -f

Hi @PsiDoc looks like the script added a static route to your system that broke the PC’s connection to plex.tv. A couple things to try. What’s the output of the below command?

route print

Would you feel comfortable doing a full network reset? You’ll lose saved Wifi passwords, and potentially also lose your VPN configuration, and will need to set these up again. Additionally, things like static IP address, or other network configs may be cleared too.

If you’re okay with that, assuming you’re using Windows 10, you can open settings and go to Network & Internet > Network Reset.

If you’re not okay with that, you’ll need to clear the route from the routing table, which the command above will help us achieve. Let me know what you’d like to do :slight_smile:

I’m on Windows 7 and would be comfortable with a Network reset if we need to go that route.

Route print spits out the following:

Thanks for that! As far as I know, Windows 7 doesn’t have an easy one-click network reset like Win10 does. No worries. For now, this should (fingers crossed) solve the issue for you!

You need to (one-by-one) delete each of the below 5 routes:

To do this, run:

route -p delete <route_ip_address>

i.e.

route -p delete 99.80.231.223

After you’ve completed this for all of the routes I highlighted, reboot for good measure, and let me know if you can reach plex.tv :slight_smile:

Edited to add the -p flag, as these are persistent routes

Thanks, I’ll do so now and update with a reply.

UPDATE: Browser is able to load plex.tv, so I think that did the trick, Simon. Thank you very much.

I will reinstall plex media server and confirm with another update.

1 Like

Glad I could help! Let me know how it goes.

I’m sure I don’t need to say this, but I can only recommend that you’re careful with scripts like this in future, as it’s often not supported by Plex, and it’s not always something that forum users will be able to help you out with! :sweat_smile:

I will heed those words of caution.

Server installed and looks like we’re cooking. Thanks again.

1 Like

You’re welcome! Enjoy having your media back :smiley:

Looks like I spoke a little too soon, Simon. My PMS started matching content and I am able to stream shows on Plex, as well as access settings and update the server. However, I still don’t have access to my libraries. When I try to load them, I get the following screen.

Just in case, I reran route print

Do I need to get rid of the 2 remaining persistent routes? (It didn’t seem so from the prior reply.) Thanks for your continued assistance.

The default route (0.0.0.0) should be fine to leave as it is, but removing the 108.128.0.0 route may help.

Removed the top static route but it didn’t help. Ran a repair and that didn’t help either. I’m stumped again.

No worries. We’re starting to get into more drastic measures here. If you run the below line, it should clear your routes completely:

netsh interface ip delete destinationcache

Afterwards, reboot and let me know what route print says :slight_smile:

Unfortunately still the same behavior on PMS. Route print output below. If resetting the comms stack doesn’t work, then should I consider restoring to a backup point?

That’s possibly a good solution, if you’ve got a recent backup. Alternatively, following the Windows 7 instructions here may help, though I’ve not tried this myself personally, and don’t have a Windows device to test it on at the moment:

I’ll give it a go and get back to you.

1 Like

Good luck!

I don’t recommend that nuclear option… the netsh int reset all command doesn’t work and the end result of all of them was no internet connection whatsoever. Yeesh, so I pulled the chord and restored to a backup from 9AM this morning.

I AM HAPPY TO REPORT PLEX WORKS AGAIN. For once, Windows came through.

Thanks again, Simon.

1 Like

Sorry about the bad advice there! Windows networking can get pretty hairy. Glad you’re back up and running though :smiley:

No worries about the advice; I had been eyeing that article all day, so I would have tried it anyway.