The JVM will not start remote JMX because others can read the password file
Your error
Error: Password file read access must be restricted: /opt/app/jmx/jmxremote.password1 more line it can showFix it fast
Most common cause, 1 of 3Group or other users can read the file on the host
Hand the file to the account that launches java and strip every group and other bit.
sudo chown appuser:appuser /opt/app/jmx/jmxremote.password
sudo chmod 600 /opt/app/jmx/jmxremote.passwordShort answer
Error: Password file read access must be restricted means the JMX agent found group or other permission bits on jmxremote.password and stopped the JVM. The JDK accepts only a file its owner alone can read and write. Run chmod 600 as the account that starts java; in images and Kubernetes, set the mode when the file is copied or mounted.
Which cause do you have?
List the file named in the message with its mode and owner, and note which user runs the java process. The mode string shows which cause below applies.
ls -l /opt/app/jmx/jmxremote.password
ps -eo user,args | grep '[j]ava'Then find the line you see in this list and open its fix:
- 1Group or other users can read the file on the host
ls -l shows -rw-r--r-- or -rw-r----- for the password file - 2The image copied the file with the mode it had on your machine
The same flags work on the host, but the container exits at start with the error - 3A Kubernetes Secret mounts the file with the default mode 0644
The pod starts crash-looping with the error right after the password file moved into a Secret volume
What does the error look like?
Error: Password file read access must be restricted: /opt/app/jmx/jmxremote.passwordPassword file read access must be restricted
Cause 1 of 3
Group or other users can read the file on the host
You seels -l shows -rw-r--r-- or -rw-r----- for the password file
Check
The agent prints Password file read access must be restricted when any read or write bit for group or others is set on the password file. The JDK's native check tests exactly those four bits, and Oracle's JMX guide tells you to leave read and write to the owner only, because the file stores passwords in clear text.
stat -c '%a %U:%G %n' /opt/app/jmx/jmxremote.password # GNU stat, LinuxFix
Hand the file to the account that launches java and strip every group and other bit. That account must still be able to read it: a root-owned 600 file under a non-root JVM swaps this error for Password file not readable.
sudo chown appuser:appuser /opt/app/jmx/jmxremote.password
sudo chmod 600 /opt/app/jmx/jmxremote.passwordVerify
Restart the JVM with the same flags. The error is gone and the port set in com.sun.management.jmxremote.port (9010 here) is listening.
ss -ltn | grep 9010Confirmed by docs.oracle.com
Cause 2 of 3
The image copied the file with the mode it had on your machine
You seeThe same flags work on the host, but the container exits at start with the error
Check
Inside a container image the mode usually comes from COPY. Docker keeps the permissions a file has in a local build context, gives files from a Git URL context mode 644, and makes copied files owned by UID 0 unless --chown is given.
docker run --rm --entrypoint ls my-app -l /opt/app/jmx/jmxremote.passwordFix
Set owner and mode in the COPY instruction, using the user the image runs java as.
COPY --chown=appuser:appuser --chmod=600 jmxremote.password /opt/app/jmx/jmxremote.password
USER appuserVerify
The listing inside the new image shows -rw------- with appuser as owner, and the container stays up.
docker build -t my-app .
docker run --rm --entrypoint ls my-app -l /opt/app/jmx/jmxremote.passwordConfirmed by docs.docker.com
Cause 3 of 3
A Kubernetes Secret mounts the file with the default mode 0644
You seeThe pod starts crash-looping with the error right after the password file moved into a Secret volume
Check
Kubernetes writes each Secret key as a file with mode 0644 when the volume names no mode. Those group and other read bits are exactly what the JMX agent refuses.
kubectl logs my-pod --previous | grep -i "password file"
kubectl get pod my-pod -o jsonpath='{.spec.volumes[*].secret}'Fix
Add defaultMode to the secret volume. YAML takes the octal form; a JSON manifest needs the decimal value 256 for 0400. The JVM user must still be allowed to read the file, or the agent reports Password file not readable instead.
# pod spec; the container mounts jmx-auth at /etc/jmx
volumes:
- name: jmx-auth
secret:
secretName: jmx-auth
defaultMode: 0400Verify
The mounted file shows -r-------- and the pod reaches Running.
kubectl exec my-pod -- ls -lL /etc/jmx/jmxremote.passwordConfirmed by kubernetes.io
How do I stop it coming back?
- Keep jmxremote.password in a private directory of the service account, not in the shared JDK folder, as the Oracle guide advises for machines with several users.
- Set the mode where the file is created (COPY --chmod, defaultMode, your provisioning script), so a redeploy cannot quietly reset it to 644.
- Make the entrypoint or service unit check the file with stat before java starts and exit with a clear message when the mode is not 600 or 400.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro, TaxiDex.