Trying to start Sonarqube as a docker container;
docker run -d --name sonarqube 
-p 9000:9000 
-e sonar.jdbc.username=sonarqube 
-e sonar.jdbc.password=sonarqube 
-e sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube 
sonarqube
2019.08.05 13:20:39 ERROR web[o.s.s.p.Platform] Web server startup failed
java.lang.IllegalStateException: Fail to connect to database
at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:90)
…
Database is reachable from the command line.
Any help is appreciated.
             
            
              
              
              
            
            
           
          
            
            
              Welcome to the community !
if your database is on the docker host, localhost from whithin your SonarQube container refer to the container, not the host.
To refer to the host ip, you can use host.docker.internal :
-e sonar.jdbc.url=jdbc:postgresql://host.docker.internal:5432/sonarqube
You need Docker at least 18.03 to have this feature available.
Hope this help
             
            
              
              
              
            
            
           
          
            
            
              hi @pierreguillot ,
i have installed postgreSQL(not image) in EC2 and same EC2 , i ran sonarqube latest docker image with below command , but i get same error as “java.lang.IllegalStateException: Can not connect to database”
docker run --ulimit nofile=131072:131072  -d --name sonarqube -p 9000:9000 -e sonar.jdbc.url=jdbc:postgresql://hostIP:5432/sonar -e sonar.jdbc.username=sonar -e sonar.jdbc.password=sonar sonarqube