Keeping TS Server Alive After Apache Restart

Hi All.

Is there a way that i can keep Teamspeak server ‘alive’ whilst restarting the webserver (Apache) ?

I do a lot with other things on my server and often restart Apache. TS is the only thing that dies when I do that and have to restart TS each time again.

If there is a way I would like to hear how :grinning:

Thx in advance.

Your teamspeak server shouldn’t shut down when you restart your apache2 web server.
Does your Teamspeak Server crash? (Check log files)

And how do you restart your apache2 web server?
With systemctl restart apache2?
Or do you reboot your whole server / the whole system?

1 Like

Could it be that the server is using MariaDB / MySQL and the Apache restart also restarts the database server?
You can not take the database offline while TS server wants to use it!

OR could it be that a console where server was started in also does close?
Should not be a problem when startscript was used to run the server.


Yes Marcel i use that. TS then shuts down.

Chris, yes the server uses MySQL. I am not sure about any of this tbh. Sorry for noob question.

It is not a HUGE problem but it would be nice not to have to keep restarting it.

Are you sure about that?
I’ve noticed TeamSpeak doesn’t crash anymore if you gonna shutdown the database.
Instead it logs an error in the instance log and tries to push the queries later on (afaik).

Anyways… I’ve never heard of Apache being a dependency of MySQL.
Both services are independent and shouldn’t affect each other on a restart.
(at least not if you manually change that behavior)

It sounds more like this is the case.


Did you actually setup TeamSpeak as service?
Could you please post your instance log as well?


When I restart Apache: The last line is added in the log.

2021-06-12 12:31:24.388334|INFO |ServerLibPriv | |TeamSpeak 3 Server 3.13.3 (2020-12-16 14:17:05)
2021-06-12 12:31:24.388424|INFO |ServerLibPriv | |SystemInformation: Linux 4.15.0-144-generic #148-Ubuntu SMP Sat May 8 02:33:43 UTC 2021 x86_64 Binary: 64bit
2021-06-12 12:31:24.388440|WARNING |ServerLibPriv | |The system locale is set to “C” this can cause unexpected behavior. We advice you to repair your locale!
2021-06-12 12:31:24.388452|INFO |ServerLibPriv | |Using hardware aes
2021-06-12 12:31:24.388798|INFO |DatabaseQuery | |dbPlugin name: SQLite3 plugin, Version 3, ©TeamSpeak Systems GmbH
2021-06-12 12:31:24.388817|INFO |DatabaseQuery | |dbPlugin version: 3.11.1
2021-06-12 12:31:24.388922|INFO |DatabaseQuery | |checking database integrity (may take a while)
2021-06-12 12:31:24.413957|WARNING |Accounting | |Unable to open licensekey.dat, falling back to limited functionality
2021-06-12 12:31:24.414066|INFO |Accounting | |Licensing Information
2021-06-12 12:31:24.414081|INFO |Accounting | |licensed to : Anonymous
2021-06-12 12:31:24.414091|INFO |Accounting | |type : No License
2021-06-12 12:31:24.414104|INFO |Accounting | |starting date : Thu Oct 1 00:00:00 2020
2021-06-12 12:31:24.414115|INFO |Accounting | |ending date : Tue Nov 1 00:00:00 2022
2021-06-12 12:31:24.414124|INFO |Accounting | |max virtualservers: 1
2021-06-12 12:31:24.414132|INFO |Accounting | |max slots : 32
2021-06-12 12:31:25.071607|INFO | | |Puzzle precompute time: 643
2021-06-12 12:31:25.071949|INFO |FileManager | |listening on, [::]:30033
2021-06-12 12:31:25.073015|INFO |Query | |Using a query thread pool size of 2
2021-06-12 12:31:25.106472|INFO |Query | |listening for query on, [::]:10011
2021-06-12 12:31:25.106638|INFO |Query | |listening for ssh query on, [::]:10022
2021-06-12 12:31:25.106715|INFO |Query | |listening for http query on, [::]:10080
2021-06-12 12:31:25.106776|INFO |CIDRManager | |updated query_ip_allowlist ips:, ::1/128,
2021-06-12 12:32:21.023865|INFO |ServerMain | |Received signal SIGTERM, shutting down.

Another Log also made:

2021-06-12 12:31:25.106321|INFO |VirtualServerBase|1 |listening on, [::]:9987
2021-06-12 12:32:21.024308|INFO |VirtualServerBase|1 |stopped

Alright we’re getting closer to find your issue.

INFO |ServerLibPriv | |TeamSpeak 3 Server 3.13.3 (2020-12-16 14:17:05)

First of all just as tip, update your server to the latest version (3.16.6) - download it here.
That’s not the cause of your problem but recommended anyways.

INFO |DatabaseQuery | |dbPlugin name: SQLite3 plugin, Version 3

Your server is using SQLite, no external database environment.
That means a restart of MySQL if that’s even installed on your system doesn’t affect TeamSpeak at all.
Restarting Apache2 doesn’t affect TeamSpeak, too as I mentioned above as well as it doesn’t affect MySQL if it would be installed your system.

WARNING |ServerLibPriv | |The system locale is set to “C” this can cause unexpected behavior. We advice you to repair your locale!

You should think about to change your system locate to get rid of this warning.
(it’s basically the language configuration of your local system)
Still this shouldn’t be the cause of receiving a shutdown signal but let’s fix this as well.

SystemInformation: Linux 4.15.0-144-generic #148-Ubuntu SMP

TeamSpeak requires to use en_US.UTF-8 or de_DE.UTF-8.

Display all available locales: locale -a

If both packages are missing, generate them: locale-gen en_US.UTF-8 or locale-gen de_DE.UTF-8

Adjust the default settings found in the file /etc/default/locale
Add/edit the var LANG and save the file: LANG=en_US.UTF-8 or LANG=de_DE.UTF-8

An alternative way to update the default system local without editing the file:
update-locale LANG=en_US.UTF-8 or update-locale LANG=de_DE.UTF-8

Reboot the server as last step.

I somehow still think TS.ChrisR is right with that statement.


How do actually start your TeamSpeak server?
Do you start the server using the startscript manually in the terminal?
As I’ve asked above already, did you setup your TeamSpeak server as service?

Without answering these questions I’m not able to go on investigate your issue.

1 Like

This is the important line:

2021-06-12 12:32:21.023865|INFO |ServerMain | |Received signal SIGTERM, shutting down.

Maybe tell us how exactly you restart your apache2 webserver.

1 Like

You want to restart the apache2 service right? Just run the Command service apache2 restart
You can see the state of every service with service --status-all

systemctl restart apache2 or service apcahe2 restart --there are a few ways but it does not matter which one i use. The result is the same.

@FakE the locale is set with en_US.UTF-8 - That’s the only entry on that file. I did update the server to 3.16.6 because server was then not getting scanned by Gametracker. I downgraded again. As you said I dont think it is that because it has been like this for many versions.

@TS.ChrisR I start the server with a self made panel on a webpage.

I cannot type the script in a reply because i get an error but it is PHP script basically executing the start.

exec(’/home/smiley/cod4/commands/’); exit;

That is the problem. You need to replace the exec command with the actual Startscript. Otherwise the TeamSpeak process is part of the apache process and shutdown with the apache process.


That did not work. Permissions are correct but TS does not start that way. Example: /home/smiley/ts3/

I press the button on my webpage and that points to the php file : exec(’/home/smiley/cod4/commands/’); exit;

That file / reads:

cd /home/smiley/ts3

Server starts no problem. Have the same with a stop button. Changing the path in the forst instance to the sh file within ts3 directory did not work. Maybe missing something here :frowning:

Try to use systemd to start ts3.

ie: systemctl start ts3 if you have a service with that name.


I did not have it running as a service. So obviously got me thinking. I did this:

sudo nano /lib/systemd/system/ts3server.service

Then added the script below obviously changing the paths:

Description=Teamspeak Service

ExecStop=/home/teamspeak/ stop
ExecReload=/home/teamspeak/ restart


Saved the file and then enabled it : systemctl enable ts3server.service

Rebooted my machine and then checked with: systemctl status ts3server

ts3 was active and running. Now when I restart Apache (disconnects me form ts3 for about 10 seconds and then reconnects) or my machine it stays running. That is also starting and stopping ts3 from my home made control panel.

Thank you all very much for the help and the shove that I needed in the right direction. :woozy_face:

Just a few more words about your build.

Your PHP script starting and stopping the server has nothing to do with the service at all.
The proper installation of the service is important if you wanna restart your server automatically.
(on a crash/system reboot)

Your service is not setup correctly as it is.

The does not create a PID file by default.
The requires a PID to check if process is still running.

Description=Teamspeak Service

ExecStart=/home/teamspeak/ start
ExecStop=/home/teamspeak/ stop
ExecReload=/home/teamspeak/ restart


By using the to start the server you will make sure to create a PID file.
Additionally the service will add the parameter (PIDFile) if it (re)starts the application.

Back to your PHP script…

As first make sure your service is active and running (systemctl status ts3server).

Check if the user the webserver is running by - probably www-data - has the permission to access services.

exec( "systemctl stop ts3service" ); exit;

If so just update your script to start and stop the application in the future using the service.

If not make sure to start the application at least by using the
This will automatically create the required PID file I mentioned above.

exec( "./home/teamspeak/ start" ); exit;

:warning: Keep in mind as long as you use the startscript and not the service in your PHP script, the application will be part of your webservers process. That means it will be shutdown if your webserver reboots.
It does start automatically only because your service is still enabled.
The webserver doesn’t start the process by it’s own.


Thanks FakE that a great detailed description. I have done as you said and all seems to be ok :slight_smile:

1 Like
twitch instagram twitter facebook