错误信息:
(base) usr@MacBook-Air ~ % sudo neo4j console
Password:
Directories in use:
home: /opt/homebrew/Cellar/neo4j/5.18.1/libexec
config: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/conf
logs: /opt/homebrew/var/log/neo4j
plugins: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/plugins
import: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/import
data: /opt/homebrew/var/neo4j/data
certificates: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/certificates
licenses: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/licenses
run: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/run
Starting Neo4j.
2024-03-24 06:18:20.098+0000 INFO Logging config in use: File '/opt/homebrew/Cellar/neo4j/5.18.1/libexec/conf/user-logs.xml'
2024-03-24 06:18:20.104+0000 INFO Starting...
2024-03-24 06:18:21.167+0000 INFO This instance is ServerId{38d38472} (38d38472-ceec-4589-bbf6-88df46eb87a2)
2024-03-24 06:18:21.516+0000 INFO ======== Neo4j 5.18.1 ========
2024-03-24 06:18:28.567+0000 ERROR Failed to start Neo4j on localhost:7474.
java.lang.RuntimeException: Error starting Neo4j database server at /opt/homebrew/var/neo4j/data/databases
at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:276) ~[neo4j-5.18.1.jar:5.18.1]
at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.build(DatabaseManagementServiceFactory.java:211) ~[neo4j-5.18.1.jar:5.18.1]
at org.neo4j.server.CommunityBootstrapper.createNeo(CommunityBootstrapper.java:38) ~[neo4j-5.18.1.jar:5.18.1]
at org.neo4j.server.NeoBootstrapper.start(NeoBootstrapper.java:184) [neo4j-5.18.1.jar:5.18.1]
at org.neo4j.server.NeoBootstrapper.start(NeoBootstrapper.java:99) [neo4j-5.18.1.jar:5.18.1]
at org.neo4j.server.CommunityEntryPoint.main(CommunityEntryPoint.java:30) [neo4j-5.18.1.jar:5.18.1]
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.bolt.protocol.common.connector.netty.SocketNettyConnector@1a06ec24' was successfully initialized, but failed to start. Please see the attached cause exception "bind(..) failed: Address already in use".
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:364) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:91) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.bolt.BoltServer.start(BoltServer.java:354) ~[neo4j-bolt-5.18.1.jar:5.18.1]
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:347) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:91) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:267) ~[neo4j-5.18.1.jar:5.18.1]
... 5 more
Caused by: org.neo4j.configuration.helpers.PortBindException: An error occurred while trying to bind to the socket localhost/127.0.0.1:7687
at org.neo4j.bolt.protocol.common.connector.netty.AbstractNettyConnector.start(AbstractNettyConnector.java:199) ~[neo4j-bolt-5.18.1.jar:5.18.1]
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:347) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:91) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.bolt.BoltServer.start(BoltServer.java:354) ~[neo4j-bolt-5.18.1.jar:5.18.1]
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:347) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:91) ~[neo4j-common-5.18.1.jar:5.18.1]
at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(DatabaseManagementServiceFactory.java:267) ~[neo4j-5.18.1.jar:5.18.1]
... 5 more
Caused by: io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
2024-03-24 06:18:28.570+0000 INFO Neo4j Server shutdown initiated by request
2024-03-24 06:18:28.571+0000 INFO Stopped.
Neo4j web server failed to start. See log for more info.
Run with '--verbose' for a more detailed error message.
解决办法:
找了很多国内外的经验贴,有说权限不够加sudo的,也有说把/labs目录下的apoc-5.18.1-core.jar移动到/plugins目录下的(Facing Issue while installing 5.15 apoc - Desktop - Neo4j Online Community),但对我来说都没有用
最终的原因是端口7474已经有一个进程在运行了,把这个进程kill掉就可以了(Database failed to start, exited with status 'KILLED" - `Caused by: ... bind(..) failed: Address already in use` - Desktop - Neo4j Online Community)
(base) usr@MacBook-Air ~ % lsof -i :7474
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Code\x20H 67013 usr 118u IPv4 0x88e6dff3e36ec84b 0t0 TCP localhost:7474 (LISTEN)
(base) usr@MacBook-Air ~ % kill 67013
(base) usr@MacBook-Air ~ % lsof -i :7474
(base) usr@MacBook-Air ~ % sudo neo4j console
Directories in use:
home: /opt/homebrew/Cellar/neo4j/5.18.1/libexec
config: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/conf
logs: /opt/homebrew/var/log/neo4j
plugins: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/plugins
import: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/import
data: /opt/homebrew/var/neo4j/data
certificates: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/certificates
licenses: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/licenses
run: /opt/homebrew/Cellar/neo4j/5.18.1/libexec/run
Starting Neo4j.
2024-03-24 06:22:05.901+0000 INFO Logging config in use: File '/opt/homebrew/Cellar/neo4j/5.18.1/libexec/conf/user-logs.xml'
2024-03-24 06:22:05.907+0000 INFO Starting...
2024-03-24 06:22:06.760+0000 INFO This instance is ServerId{38d38472} (38d38472-ceec-4589-bbf6-88df46eb87a2)
2024-03-24 06:22:07.114+0000 INFO ======== Neo4j 5.18.1 ========
2024-03-24 06:22:08.446+0000 INFO Bolt enabled on localhost:7687.
2024-03-24 06:22:08.784+0000 INFO HTTP enabled on localhost:7474.
2024-03-24 06:22:08.784+0000 INFO Remote interface available at http://localhost:7474/
2024-03-24 06:22:08.785+0000 INFO id: 1E401ADFCA86EEFC56F543E68E9D9A6BF22C149E054843C74785E1CCA20E57DF
2024-03-24 06:22:08.785+0000 INFO name: system
2024-03-24 06:22:08.785+0000 INFO creationDate: 2024-03-24T04:31:41.977Z
2024-03-24 06:22:08.785+0000 INFO Started.
顺利启动