Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

366
Vistas
linux apache python cgi error: failed to get random numbers to initialize Python

My old CentOS 5 apache server can run Perl script CGI without any problem.

# cat t1.cgi
#!/usr/local/bin/perl

use CGI;
my $cgi = CGI->new();
print $cgi->header;

print "Test\n"; 



# GET HTTP://www.example.com/cgi/t1.cgi
Test

python scripts can be run under shell without any problem:

# cat t2.cgi
#!/usr/local/bin/python3

print("Content-Type: text/html\n")


print("hello!")

# python3 t2.cgi                                                                                                                                                              
Content-Type: text/html

hello!

but failed as a python cgi script:

# GET http://www.example.com/cgi/t2.cgi
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
500 Internal Server Error
</BODY>
</HTML>

apache error logs show the error was:

Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python
Python runtime state: preinitialized

Premature end of script headers: t2.cgi

any idea will be appreciated!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

fixed it by

mknod -m 444 /dev/random
chmod 444 /dev/urandom

my old centos don't have /dev/random, and the default file mode for urandom was 600, read only by root.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda